diff options
Diffstat (limited to 'java/java-tests')
68 files changed, 707 insertions, 156 deletions
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef-out.java b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef-out.java new file mode 100644 index 000000000000..19decec183b0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef-out.java @@ -0,0 +1,14 @@ +@FunctionalInterface +interface Foo9 { + Bar test(int p); +} + +class Bar { + public Bar(int p) {} +} + +class Test88 { + void foo(Foo9 foo) { + foo(Bar::new<caret>); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef.java b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef.java new file mode 100644 index 000000000000..7f7af003b377 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/ConstructorRef.java @@ -0,0 +1,14 @@ +@FunctionalInterface +interface Foo9 { + Bar test(int p); +} + +class Bar { + public Bar(int p) {} +} + +class Test88 { + void foo(Foo9 foo) { + foo(Bar::<caret>); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames-out.java new file mode 100644 index 000000000000..48157c4ded2a --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames-out.java @@ -0,0 +1,10 @@ +interface I<T> { + void m(T t, String s); +} + +class Test { + public static void main(String[] args) { + String s = ""; + I<String> i = (s1, s2) -> <caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames.java new file mode 100644 index 000000000000..e7adb2ffb758 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSameNames.java @@ -0,0 +1,10 @@ +interface I<T> { + void m(T t, String s); +} + +class Test { + public static void main(String[] args) { + String s = ""; + I<String> i = <caret> + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java b/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java index 38024980a233..4c765169c38f 100644 --- a/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java +++ b/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java @@ -11,7 +11,7 @@ public class Test { @Override void bar() { - + } } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java index 171b63a8f06f..de5212a4bf87 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java @@ -90,5 +90,6 @@ class T1 { ++(<error descr="Variable 'i2' might not have been initialized">i2</error>); <error descr="Variable 'i3' might not have been initialized">i3</error> += 1; (i4) = 1; + (<error descr="Expression expected">)</error>++; } }
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TypeCastInInstanceof.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TypeCastInInstanceof.java new file mode 100644 index 000000000000..cbbffdf44291 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TypeCastInInstanceof.java @@ -0,0 +1,13 @@ +@SuppressWarnings({"UnusedDeclaration"}) +class C { + boolean foo(final ConfigurableField<String> nameField) { + return (Formatter<?>)nameField.getFormatter() instanceof DefaultFormatter; + } +} + +@SuppressWarnings({"UnusedDeclaration"}) +interface Formatter<V>{} +class DefaultFormatter implements Formatter<Object>{} +interface ConfigurableField<V> { + Formatter<V> getFormatter(); +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/dupMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/dupMethods.java new file mode 100644 index 000000000000..94744fa9be03 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/dupMethods.java @@ -0,0 +1,4 @@ +@interface Example { + <error descr="'myMethod()' is already defined in 'Example'">public String myMethod()</error>; + <error descr="'myMethod()' is already defined in 'Example'">public int myMethod()</error>; +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/privateInaccessibleConstant.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/privateInaccessibleConstant.java new file mode 100644 index 000000000000..435810d00b44 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/privateInaccessibleConstant.java @@ -0,0 +1,8 @@ +@FooAnnotation(<error descr="'Foo.BAR' has private access in 'Foo'">Foo.BAR</error>) +class Foo { + private static final String BAR = "bar"; +} + +@interface FooAnnotation { + String value(); +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA55510.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA55510.java index 5776db03ae4b..2db53078fce5 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA55510.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA55510.java @@ -34,3 +34,20 @@ class Records { } } } +//--------------------------------------------- +class Parent<T extends Parent.NestedParent> +{ + protected static interface NestedParent + { + } +} + +class Test +{ + public final static class Child extends Parent<<error descr="NestedChild is not accessible in current context">Child.NestedChild</error>> + { + private static interface NestedChild extends NestedParent + { + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA78402.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA78402.java new file mode 100644 index 000000000000..ed8d259ab462 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA78402.java @@ -0,0 +1,18 @@ +import java.util.Collection; +import java.util.List; + +class Reference<T> {} + +class Bug { + private static <T> void foo(List<T> x, Reference<String> y) { + System.out.println(x); + } + + private static <T> void foo(Collection<T> x, Reference<T> y) { + System.out.println(x); + } + + public static void bazz(List<String> bar) { + foo<error descr="Ambiguous method call: both 'Bug.foo(List<String>, Reference<String>)' and 'Bug.foo(Collection<String>, Reference<String>)' match">(bar, null)</error>; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA78402.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA78402.java new file mode 100644 index 000000000000..ed8d259ab462 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA78402.java @@ -0,0 +1,18 @@ +import java.util.Collection; +import java.util.List; + +class Reference<T> {} + +class Bug { + private static <T> void foo(List<T> x, Reference<String> y) { + System.out.println(x); + } + + private static <T> void foo(Collection<T> x, Reference<T> y) { + System.out.println(x); + } + + public static void bazz(List<String> bar) { + foo<error descr="Ambiguous method call: both 'Bug.foo(List<String>, Reference<String>)' and 'Bug.foo(Collection<String>, Reference<String>)' match">(bar, null)</error>; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA127928.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA127928.java new file mode 100644 index 000000000000..d0c118198599 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA127928.java @@ -0,0 +1,21 @@ +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +class CastLambdaParameter { + + void main(final Map<Integer, String> map) { + Set<Function<Object, String>> property2formatter = foo(bar((joint) -> map.get((Integer)joint))); + } + + public static <B> Set<B> foo(List<B> property2name) {return property2name != null ? null : null;} + public static <B> Set<B> foo(List<B>... property2name) {return property2name != null ? null : null;} + public static <B> Set<B> foo(Set<B> property2name) {return property2name != null ? null : null;} + + public static <TB> List<TB> bar(TB b) { + return null; + } + +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallOverloads.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallOverloads.java new file mode 100644 index 000000000000..6506a7a48464 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallOverloads.java @@ -0,0 +1,16 @@ +import java.util.List; +import java.util.Set; + +abstract class Overloadsss { + abstract <T> List<T> foo(List<T> l); + abstract <T> Set<T> foo(Set<T> s); + + abstract <K> List<K> bar(List<K> l); + abstract <K> List<K> bar1(List<K> l); + abstract <K> Set<K> bar1(Set<K> s); + + { + List<String> l = foo(bar (null)); + List<String> l1 = foo(bar1<error descr="Ambiguous method call: both 'Overloadsss.bar1(List<Object>)' and 'Overloadsss.bar1(Set<Object>)' match">(null)</error>); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/AnnotationTypeExtensionsNotSupported.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/AnnotationTypeExtensionsNotSupported.java new file mode 100644 index 000000000000..258bf1132d5b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/AnnotationTypeExtensionsNotSupported.java @@ -0,0 +1,9 @@ +@interface Example { + + public <error descr="Modifier 'static' not allowed here">static</error> String myMethod() { + return ""; + } + public <error descr="Modifier 'default' not allowed here">default</error> String myMethod1() { + return ""; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA123951.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA123951.java new file mode 100644 index 000000000000..c5bdecf7c43e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA123951.java @@ -0,0 +1,8 @@ + +import java.util.stream.Collectors; + +class Test { + { + Collectors.mapping(i -> 1, Collectors.summingInt(s -> s.intValue())); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124190.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124190.java new file mode 100644 index 000000000000..9885b03ffaa9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124190.java @@ -0,0 +1,12 @@ +import java.util.*; +import java.util.stream.Stream; + +class Test { + + void foo(final Stream<String> stream){ + stream.collect(ArrayList::new, ArrayList::add, ArrayList::addAll); + stream.collect(ArrayList<String>::new, ArrayList::add, ArrayList::addAll); + stream.collect(ArrayList::new, Collection::add, Collection::addAll); + } + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java new file mode 100644 index 000000000000..369804623026 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java @@ -0,0 +1,12 @@ +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + +class Main { + void bar(final Stream<Object> objectStream) { + foo(objectStream.map(o -> "str").collect(toList())); + } + + void foo(Iterable<?> k){} + void foo(String s){} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124983.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124983.java new file mode 100644 index 000000000000..2a92ebe2accf --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124983.java @@ -0,0 +1,9 @@ + +import java.util.stream.IntStream; + +class Test { + private void foo(final IntStream range) { + range.mapToObj(i -> range.mapToObj(j -> 1)) + .flatMap(s -> s); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125674.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125674.java new file mode 100644 index 000000000000..92d8de505e95 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA125674.java @@ -0,0 +1,8 @@ +import java.util.stream.Collectors; +import java.util.stream.Stream; + +class Test { + void foo(final Stream<String> stream){ + stream.collect(Collectors.toMap(s -> s, s -> s, (a, b) -> a.length() > b. length() ? a : b)); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java new file mode 100644 index 000000000000..cb8442e59d12 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java @@ -0,0 +1,30 @@ +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +class Test { + private static class Thing { + final String val; + public Thing(String val) { + this.val = val; + } + } + + public static Optional<List<String>> highlights() { + return Optional.of(Collections.singletonList(new Thing("Hello"))) + .map(l -> l + .stream() + .map(t -> t.val + " world!") + .collect(Collectors.toList())); + } + + public static Optional<List<String>> works() { + return Optional.of(Collections.singletonList(new Thing("Hello"))) + .map(l -> l + .stream() + .map(t -> t.val + " world!") + .collect(Collectors.toList())); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275.java new file mode 100644 index 000000000000..6b3a6123fa09 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275.java @@ -0,0 +1,18 @@ +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +class Main { + { + List<Optional<Function<String, String>>> list = asList(of(Main::identity)); + } + + static <T> List<T> asList(T... a) { return null;} + + static <T> Optional<T> of(T value) { return null;} + + public static String identity(final String s) { + return s; + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275_.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275_.java new file mode 100644 index 000000000000..c002468c1b91 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA127275_.java @@ -0,0 +1,19 @@ +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +class Main { + { + List<Optional<Function<String, String>>> list = asList(of(Main::identity)); + } + + static <T> List<T> asList(T a) { return null;} + static <T> List<T> asList(Optional a) { return null;} + + static <T> Optional<T> of(T value) { return null;} + + public static String identity(final String s) { + return s; + } + +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128534.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128534.java new file mode 100644 index 000000000000..74b4322196b8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128534.java @@ -0,0 +1,10 @@ +import java.util.Set; + +class Test { + + public static void foo(String[] args, final Set<Test> singleton) { + singleton.forEach(Test::m); + } + + public static void m(Test... others) {} +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128712.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128712.java new file mode 100644 index 000000000000..3a812195b86f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA128712.java @@ -0,0 +1,19 @@ +import java.util.Collection; +import java.util.function.Function; +import java.util.stream.Stream; + +abstract class Foo { + { + map(Foo::bar); + map(a -> Foo.bar(a)); + } + + <R> Stream<R> map(Function<Class<?>, ? extends R> mapper) { + return null; + } + + + private static <T> Collection<T> bar(Class<T> baseClass) { + return null; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/UnresolvedMethodReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/UnresolvedMethodReference.java new file mode 100644 index 000000000000..cee3a33a1230 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/UnresolvedMethodReference.java @@ -0,0 +1,9 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +class Main { + public void test() { + Collections.sort(new ArrayList<>(), Comparator::<error descr="Cannot resolve method 'reversed'">reversed</error>); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup.java new file mode 100644 index 000000000000..9d516996894c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup.java @@ -0,0 +1,11 @@ +// "Create Inner Class 'AInner'" "true" +class Test { + { + AInner aInner = new AInner<String>(42); + } + + private class AInner<T> { + public AInner(int i) { + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup1.java new file mode 100644 index 000000000000..aac015e28360 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/afterTypeParamSetup1.java @@ -0,0 +1,11 @@ +// "Create Inner Class 'AInner'" "true" +class Test { + { + AInner aInner = new AInner<String, String>(42); + } + + private class AInner<T, T1> { + public AInner(int i) { + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup.java new file mode 100644 index 000000000000..1d26d9d55357 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup.java @@ -0,0 +1,6 @@ +// "Create Inner Class 'AInner'" "true" +class Test { + { + AInner aInner = new AIn<caret>ner<String>(42); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup1.java new file mode 100644 index 000000000000..bf0997aed99e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew/beforeTypeParamSetup1.java @@ -0,0 +1,6 @@ +// "Create Inner Class 'AInner'" "true" +class Test { + { + AInner aInner = new AIn<caret>ner<String, String>(42); + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after1.java index f90b3db33828..a144d82ac59c 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after1.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after2.java index 877810ea9ade..a43c160b6d38 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after2.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/after2.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo1() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertFalse.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertFalse.java index 5aba2e1bc320..b16797331be1 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertFalse.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertFalse.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo2() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertTrue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertTrue.java index b251f0387f29..a5ded0b7ba07 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertTrue.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/afterAssertTrue.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo2() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before1.java index b012f43a1c52..698897914e67 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before1.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before2.java index e7d9398ae3e8..768ea463ff1c 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before2.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/before2.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo1() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertFalse.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertFalse.java index 8ddc67b7ac1e..49786029f303 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertFalse.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertFalse.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo2() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertTrue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertTrue.java index 98611528fce5..4aa5316be779 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertTrue.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAll/beforeAssertTrue.java @@ -1,4 +1,4 @@ -// "Fix all 'Constant conditions & exceptions' problems" "true" +// "Fix all 'Constant conditions & exceptions' problems in file" "true" public class Test { void foo2() { int k = 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/after1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/after1.java index 1a0aba5d40ef..1297d5d7fac5 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/after1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/after1.java @@ -1,4 +1,4 @@ -// "Fix all 'Annotator' problems" "true" +// "Fix all 'Annotator' problems in file" "true" public class Test { void fooF() { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/before1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/before1.java index 8006731dbe32..8805559ebe8e 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/before1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/fixAllAnnotator/before1.java @@ -1,4 +1,4 @@ -// "Fix all 'Annotator' problems" "true" +// "Fix all 'Annotator' problems in file" "true" public class Test { void f<caret>oo() { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/afterArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/afterArrayInitializer.java new file mode 100644 index 000000000000..c063aef37715 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/afterArrayInitializer.java @@ -0,0 +1,8 @@ +// "Move initializer to constructor" "true" +class X { + final String s; + + X() { + s = {}; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/beforeArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/beforeArrayInitializer.java new file mode 100644 index 000000000000..fdc8c7b3e22f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveInitializerToConstructor/beforeArrayInitializer.java @@ -0,0 +1,7 @@ +// "Move initializer to constructor" "true" +class X { + final String <caret>s = {}; + + X() { + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterArrayInitializer.java new file mode 100644 index 000000000000..fda3c915e4da --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterArrayInitializer.java @@ -0,0 +1,22 @@ +// "Surround with try/catch" "true" +public class ExTest { + public static String maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + String[] a = new String[0]; + try { + a = new String[]{maybeThrow("")}; + } catch (Ex ex) { + ex.printStackTrace(); + } + System.out.println(a); + } + + + private static class Ex extends Exception { + public Ex(String s) { + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeArrayInitializer.java new file mode 100644 index 000000000000..60e76c1781a3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/beforeArrayInitializer.java @@ -0,0 +1,17 @@ +// "Surround with try/catch" "true" +public class ExTest { + public static String maybeThrow(String data) throws Ex { + throw new Ex(data); + } + + { + String[] a = {mayb<caret>eThrow("")}; + System.out.println(a); + } + + + private static class Ex extends Exception { + public Ex(String s) { + } + } +}
\ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java index f9f70d655310..f35df4d389f9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java @@ -81,7 +81,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone(); try { CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE); - codeStyleSettings.RIGHT_MARGIN = 80; + javaSettings.RIGHT_MARGIN = 80; javaSettings.KEEP_LINE_BREAKS = true; codeStyleSettings.GENERATE_FINAL_PARAMETERS = true; javaSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; @@ -97,7 +97,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone(); try { CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE); - codeStyleSettings.RIGHT_MARGIN = 80; + javaSettings.RIGHT_MARGIN = 80; javaSettings.KEEP_LINE_BREAKS = false; codeStyleSettings.GENERATE_FINAL_PARAMETERS = false; javaSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy index b966d5205776..2b4d4af70554 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy @@ -229,6 +229,20 @@ class Foo { myFixture.assertPreferredCompletionItems 0, 'param', 'param param2' } + public void "test fqns in package info"() { + myFixture.configureByText "package-info.java", ''' +/** + * {@link java.util.Map#putA<caret>} + */ +''' + myFixture.complete(CompletionType.BASIC) + myFixture.checkResult ''' +/** + * {@link java.util.Map#putAll(java.util.Map)} + */ +''' + } + public void "test suggest same param descriptions"() { myFixture.configureByText "a.java", ''' class Foo { 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 8aee494012cb..eb3c4c4577b6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java @@ -80,6 +80,13 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase { public void testInLambdaPositionNameSubstitution() throws Exception { doTest(); } + public void testInLambdaPositionSameNames() throws Exception { + doTest(); + } + + public void testConstructorRef() throws Exception { + doTest(false); + } public void testFilteredMethodReference() throws Exception { doTest(false); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java index 964566fcf5ff..43e90b84257b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java @@ -41,6 +41,8 @@ public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testDuplicateTarget() { doTest(false); } public void testPingPongAnnotationTypesDependencies() { doTest(false);} public void testClashMethods() { doTest(false);} + public void testDupMethods() { doTest(false);} + public void testPrivateInaccessibleConstant() { doTest(false);} public void testInvalidPackageAnnotationTarget() { doTest(BASE_PATH + "/" + getTestName(true) + "/package-info.java", false, false); } public void testPackageAnnotationNotInPackageInfo() { doTest(BASE_PATH + "/" + getTestName(true) + "/notPackageInfo.java", false, false); } 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 f6be0686d239..688e83b5b198 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -371,6 +371,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA126697() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true); } public void testIDEA126633() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testIDEA124363() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testIDEA78402() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } //jdk should propagate LL 1.4 but actually it provides LL 1.7?! public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); } 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 0c561dfdace5..10d5bc064dcd 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java @@ -21,8 +21,10 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase { @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { + JavaDocLocalInspection localInspection = new JavaDocLocalInspection(); + localInspection.setIgnoreDuplicatedThrows(false); return new LocalInspectionTool[]{ - new JavaDocLocalInspection(), + localInspection, new JavaDocReferenceInspection() }; } 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 d6831d4a2d4a..c24366b3d513 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -145,6 +145,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testPreciseRethrow() { doTest(false, false); } public void testImprovedCatchAnalysis() { doTest(true, false); } public void testPolymorphicTypeCast() { doTest(true, false); } + public void testTypeCastInInstanceof() { doTest(true, false); } public void testErasureClashConfusion() { doTest(true, false, UnusedDeclarationInspection.class); } public void testUnused() { doTest(true, false, UnusedDeclarationInspection.class); } public void testSuperBound() { doTest(false, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java index 8f9167d83a21..d23dfea6daf0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java @@ -759,6 +759,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA78402() { doTest(); } + private void doTest() { doTest(false); } 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 index 6ccefa35ae51..c2ab020f09f3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -16,11 +16,14 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.idea.Bombed; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; +import java.util.Calendar; + public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference"; @@ -44,10 +47,12 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + @Bombed(day = 20, month = Calendar.AUGUST) public void testInferenceFromSiblings() throws Exception { doTest(); } + @Bombed(day = 20, month = Calendar.AUGUST) public void testChainedInferenceTypeParamsOrderIndependent() throws Exception { doTest(); } @@ -204,6 +209,14 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testOuterCallOverloads() throws Exception { + doTest(); + } + + public void testIDEA127928() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(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 index 95b3bfb7395d..2162b96db138 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java @@ -43,6 +43,9 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe public void testDefaultSupersInStaticContext() { doTest(false, false); } + public void testAnnotationTypeExtensionsNotSupported() { + doTest(false, false); + } public void testSuperProtectedCalls() throws Exception { myFixture.addClass("package p; public class Foo {" + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index ea9ada93ca77..1411249b3dcc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -18,12 +18,15 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.idea.Bombed; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.util.Calendar; + public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newLambda"; @@ -60,6 +63,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testTargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType() { doTest(); } public void testIDEA119535() { doTest(); } public void testIDEA119003() { doTest(); } + public void testIDEA125674() { doTest(); } public void testIDEA117124() { doTest(); } public void testWildcardParameterization() { doTest(); } public void testDiamondInLambdaReturn() { doTest(); } @@ -73,6 +77,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA122700() { doTest(); } public void testIDEA122406() { doTest(); } public void testNestedCallsInsideLambdaReturnExpression() { doTest(); } + @Bombed(day = 20, month = Calendar.AUGUST) public void testIDEA123731() { doTest(); } public void testIDEA123869() { doTest(); } public void testIDEA123848() { doTest(); } @@ -87,11 +92,28 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA124961() { doTest(); } public void testIDEA126109() { doTest(); } public void testIDEA126809() { doTest(); } + public void testIDEA124424() { doTest(); } public void testIDEA127596() throws Exception { doTest(); } + @Bombed(day = 20, month = Calendar.AUGUST) + public void testIDEA124983() throws Exception { + doTest(); + } + + public void testIDEA123951() throws Exception { + doTest(); + } + + public void testIDEA124190() throws Exception { + doTest(); + } + public void testIDEA127124comment() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index dd7ceb566139..c48ef71d92d4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -19,12 +19,15 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.idea.Bombed; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.util.Calendar; + public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef"; @@ -281,6 +284,27 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA127275() throws Exception { + doTest(); + } + + @Bombed(day = 20, month = Calendar.AUGUST) + public void testIDEA127275_() throws Exception { + doTest(); + } + + public void testUnresolvedMethodReference() throws Exception { + doTest(); + } + + public void testIDEA128534() throws Exception { + doTest(); + } + + public void testIDEA128712() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nizeTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nizeTest.java index 099a7f4d3f0e..03693ce742c3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nizeTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -20,6 +20,7 @@ import com.intellij.codeInspection.i18n.I18nizeAction; import com.intellij.codeInspection.i18n.JavaI18nUtil; import com.intellij.ide.DataManager; import com.intellij.lang.properties.psi.PropertiesFile; +import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ex.PathManagerEx; @@ -43,7 +44,7 @@ public class I18nizeTest extends LightCodeInsightTestCase { configureByFile(getBasePath() + "/before"+getTestName(false)+"."+ext); I18nizeAction action = new I18nizeAction(); DataContext dataContext = DataManager.getInstance().getDataContext(myEditor.getComponent()); - AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), null, 0); + AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.update(event); @NonNls String afterFile = getBasePath() + "/after" + getTestName(false) + "." + ext; boolean afterFileExists = new File(PathManagerEx.getTestDataPath() + afterFile).exists(); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/JavaDocInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/JavaDocInspectionTest.java index 0f4644a84a26..30802e8a6da3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/JavaDocInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/JavaDocInspectionTest.java @@ -33,7 +33,9 @@ public class JavaDocInspectionTest extends InspectionTestCase { } public void testDuplicateThrows() throws Exception { - doTest(); + JavaDocLocalInspection tool = new JavaDocLocalInspection(); + tool.setIgnoreDuplicatedThrows(false); + doTest("javaDocInspection/" + getTestName(true), tool); } //inherited javadoc @@ -67,7 +69,6 @@ public class JavaDocInspectionTest extends InspectionTestCase { public void testIgnoreDuplicateThrows() throws Exception { final JavaDocLocalInspection inspection = new JavaDocLocalInspection(); - inspection.IGNORE_DUPLICATED_THROWS = true; doTest("javaDocInspection/" + getTestName(true), inspection); } diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java index 7a8c5727c8eb..ac9844c4ced8 100644 --- a/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java @@ -8,7 +8,7 @@ import com.intellij.execution.executors.DefaultRunExecutor; import com.intellij.execution.junit.*; import com.intellij.execution.junit2.configuration.JUnitConfigurable; import com.intellij.execution.junit2.configuration.JUnitConfigurationModel; -import com.intellij.execution.runners.ExecutionEnvironment; +import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.execution.testframework.TestSearchScope; import com.intellij.execution.ui.CommonJavaParametersPanel; import com.intellij.openapi.module.Module; @@ -21,7 +21,10 @@ import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.ui.LabeledComponent; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.InvalidDataException; +import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; @@ -30,20 +33,23 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.rt.execution.junit.JUnitStarter; import com.intellij.rt.execution.junit.segments.SegmentedOutputStream; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.MapDataContext; +import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.PsiTestUtil; import com.intellij.ui.EditorTextFieldWithBrowseButton; import com.intellij.util.Assertion; import com.intellij.util.PathUtil; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.ContainerUtilRt; import junit.framework.TestCase; import org.jdom.Element; -import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.io.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.StringTokenizer; public class ConfigurationsTest extends BaseConfigurationTestCase { private final Assertion CHECK = new Assertion(); @@ -51,13 +57,6 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { private Sdk myJdk; private static final String INNER_TEST_NAME = "test1.InnerTest.Inner"; private static final String RT_INNER_TEST_NAME = "test1.InnerTest$Inner"; - private static final Executor MOCK_EXECUTOR = new DefaultRunExecutor() { - @NotNull - @Override - public String getId() { - return "mock"; - } - }; @Override protected void setUp() throws Exception { @@ -72,12 +71,12 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { Module module1 = getModule1(); PsiClass psiClass = findTestA(module1); JUnitConfiguration configuration = createConfiguration(psiClass); - assertEquals(Collections.singleton(module1), new HashSet(Arrays.asList(configuration.getModules()))); + assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules())); checkClassName(psiClass.getQualifiedName(), configuration); assertEquals(psiClass.getName(), configuration.getName()); checkTestObject(JUnitConfiguration.TEST_CLASS, configuration); Module module2 = getModule2(); - CHECK.compareUnordered(new Module[]{module1, module2}, configuration.getValidModules()); + Assertion.compareUnordered(new Module[]{module1, module2}, configuration.getValidModules()); PsiClass innerTest = findClass(module1, INNER_TEST_NAME); configuration = createJUnitConfiguration(innerTest, TestClassConfigurationProducer.class, new MapDataContext()); @@ -99,7 +98,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { } public void testModulesSelector() throws ConfigurationException { - if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return; + if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; Module module1 = getModule1(); Module module2 = getModule2(); @@ -117,7 +116,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { assertTrue(configurable.isModified()); configurable.apply(); assertFalse(configurable.isModified()); - assertEquals(Collections.singleton(module1), new HashSet(Arrays.asList(configuration.getModules()))); + assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules())); } finally { Disposer.dispose(editor); @@ -163,7 +162,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { JUnitConfiguration configuration = createConfiguration(psiPackage, module1); JavaParameters parameters = checkCanRun(configuration); List<String> lines = extractAllInPackageTests(parameters, psiPackage); - CHECK.compareUnordered( + Assertion.compareUnordered( new Object[]{"", psiClass.getQualifiedName(), psiClass2.getQualifiedName(), derivedTest.getQualifiedName(), RT_INNER_TEST_NAME, testB.getQualifiedName()}, lines); @@ -246,7 +245,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { newCfg.readExternal(element); checkTestObject(configuration.getPersistentData().TEST_OBJECT, newCfg); - assertEquals(Collections.singleton(getModule1()), new HashSet(Arrays.asList(newCfg.getModules()))); + assertEquals(Collections.singleton(getModule1()), ContainerUtilRt.newHashSet(newCfg.getModules())); checkClassName(configuration.getPersistentData().getMainClassName(), newCfg); } @@ -297,7 +296,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { } public void testCreatingApplicationConfiguration() throws ConfigurationException { - if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return; + if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance()); ApplicationConfigurable editor = new ApplicationConfigurable(myProject); @@ -329,7 +328,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { } public void testEditJUnitConfiguration() throws ConfigurationException { - if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return; + if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; PsiClass testA = findTestA(getModule2()); JUnitConfiguration configuration = createConfiguration(testA); @@ -357,11 +356,11 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { } } - public void testRunThridPartyApplication() throws ExecutionException { + public void testRunThirdPartyApplication() throws ExecutionException { ApplicationConfiguration configuration = - new ApplicationConfiguration("Thrid party", myProject, ApplicationConfigurationType.getInstance()); + new ApplicationConfiguration("Third party", myProject, ApplicationConfigurationType.getInstance()); configuration.setModule(getModule1()); - configuration.MAIN_CLASS_NAME = "thrid.party.Main"; + configuration.MAIN_CLASS_NAME = "third.party.Main"; checkCanRun(configuration); } @@ -407,7 +406,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { return PathUtil.getLocalPath(output); } - private String[] addOutputs(Module module, int index) { + private static String[] addOutputs(Module module, int index) { String[] outputs = new String[2]; String prefix = "outputs" + File.separatorChar; VirtualFile generalOutput = findFile(prefix + "general " + index); @@ -419,12 +418,13 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { return outputs; } - private JavaParameters checkCanRun(RunConfiguration configuration) throws ExecutionException { + private static JavaParameters checkCanRun(RunConfiguration configuration) throws ExecutionException { final RunProfileState state; - state = configuration.getState(MOCK_EXECUTOR, new ExecutionEnvironment(new MockProfile(), MOCK_EXECUTOR, myProject, null)); + state = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build().getState(); assertNotNull(state); assertTrue(state instanceof JavaCommandLine); if (state instanceof TestPackage) { + @SuppressWarnings("UnusedDeclaration") final JavaParameters parameters = ((TestPackage)state).getJavaParameters(); ((TestPackage)state).findTests(); } @@ -440,7 +440,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { return ((JavaCommandLine)state).getJavaParameters(); } - private void checkCantRun(RunConfiguration configuration, String reasonBegining) throws ExecutionException { + private void checkCantRun(RunConfiguration configuration, String reasonBeginning) throws ExecutionException { //MockRunRequest request = new MockRunRequest(myProject); //CantRunException rejectReason; //try { @@ -451,28 +451,27 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { // rejectReason = e; //} //if (rejectReason == null) fail("Should not run"); - //rejectReason.getMessage().startsWith(reasonBegining); + //rejectReason.getMessage().startsWith(reasonBeginning); try { configuration.checkConfiguration(); } catch (RuntimeConfigurationError e) { - assertTrue(e.getLocalizedMessage().startsWith(reasonBegining)); + assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning)); return; } - catch (RuntimeConfigurationException e) { + catch (RuntimeConfigurationException ignored) { } - final RunProfileState state = configuration - .getState(MOCK_EXECUTOR, new ExecutionEnvironment(new MockProfile(), MOCK_EXECUTOR, myProject, null)); + RunProfileState state = configuration.getState(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironmentBuilder(myProject, DefaultRunExecutor.getRunExecutorInstance()).runProfile(configuration).build()); assertTrue(state instanceof JavaCommandLine); try { ((JavaCommandLine)state).getJavaParameters(); } catch (Throwable e) { - assertTrue(e.getLocalizedMessage().startsWith(reasonBegining)); + assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning)); return; } @@ -537,11 +536,11 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { } private static void checkContains(String string, String fragment) { - assertTrue(fragment + " in " + string, string.indexOf(fragment) >= 0); + assertTrue(fragment + " in " + string, string.contains(fragment)); } private static void checkDoesNotContain(String string, String fragment) { - assertFalse(fragment + " in " + string, string.indexOf(fragment) >= 0); + assertFalse(fragment + " in " + string, string.contains(fragment)); } @Override @@ -549,21 +548,4 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { myJdk = null; super.tearDown(); } - - private static class MockProfile implements RunProfile { - @Override - public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException { - return null; - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public String getName() { - return null; - } - } } diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index f83d836bb55a..e40e2c160822 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -670,6 +670,18 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { assertTrue(findResult.getStartOffset() > prefix.length()); } + public void testFindExceptComments2() { + FindModel findModel = FindManagerTestUtils.configureFindModel("oo"); + + String text = "//oooo"; + + findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS); + LightVirtualFile file = new LightVirtualFile("A.java", text); + + FindResult findResult = myFindManager.findString(text, 0, findModel, file); + assertFalse(findResult.isStringFound()); + } + public void testFindExceptLiterals() { FindModel findModel = FindManagerTestUtils.configureFindModel("done"); 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 56624594bb0e..d74f7a3d0bff 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 @@ -378,6 +378,8 @@ public class DirectoryIndexTest extends IdeaTestCase { assertTrue(info.isIgnored()); assertTrue(myFileIndex.isExcluded(ignoredFile)); assertTrue(myFileIndex.isUnderIgnored(ignoredFile)); + assertNull(myFileIndex.getContentRootForFile(ignoredFile, false)); + assertNull(myFileIndex.getModuleForFile(ignoredFile, false)); } public void testAddModule() throws Exception { @@ -804,6 +806,10 @@ public class DirectoryIndexTest extends IdeaTestCase { PsiTestUtil.addExcludedRoot(myModule, fileExcludeRoot); assertFalse(myFileIndex.isInContent(fileExcludeRoot)); assertFalse(myFileIndex.isInSource(fileExcludeRoot)); + assertNull(myFileIndex.getContentRootForFile(fileExcludeRoot)); + assertEquals(myModule1Dir, myFileIndex.getContentRootForFile(fileExcludeRoot, false)); + assertNull(myFileIndex.getModuleForFile(fileExcludeRoot)); + assertEquals(myModule, myFileIndex.getModuleForFile(fileExcludeRoot, false)); assertExcluded(fileExcludeRoot, myModule); assertIteratedContent(myFileIndex, null, Arrays.asList(fileExcludeRoot)); @@ -928,7 +934,7 @@ public class DirectoryIndexTest extends IdeaTestCase { assertEquals(Arrays.toString(myIndex.getOrderEntries(info)), modulesOfOrderEntries.length, myIndex.getOrderEntries(info).length); for (Module aModule : modulesOfOrderEntries) { - OrderEntry found = myIndex.findOrderEntryWithOwnerModule(info, aModule); + OrderEntry found = ModuleFileIndexImpl.findOrderEntryWithOwnerModule(aModule, myIndex.getOrderEntries(info)); assertNotNull("not found: " + aModule + " in " + Arrays.toString(myIndex.getOrderEntries(info)), found); } } diff --git a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewSwitchingTest.java b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewSwitchingTest.java index 88641107057c..1f70167a1d8e 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewSwitchingTest.java +++ b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewSwitchingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -18,7 +18,6 @@ package com.intellij.projectView; import com.intellij.JavaTestUtil; import com.intellij.ide.favoritesTreeView.FavoritesManager; import com.intellij.ide.projectView.ProjectView; -import com.intellij.ide.projectView.impl.ProjectViewImpl; import com.intellij.ide.projectView.impl.ProjectViewPane; import com.intellij.testFramework.TestSourceBasedTestCase; @@ -29,12 +28,6 @@ public class ProjectViewSwitchingTest extends TestSourceBasedTestCase { } @Override - protected void setUp() throws Exception { - super.setUp(); - ((ProjectViewImpl)ProjectView.getInstance(getProject())).setupImpl(null); - } - - @Override protected void runStartupActivities() { FavoritesManager.getInstance(getProject()).projectOpened(); super.runStartupActivities(); diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterAlignmentTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterAlignmentTest.java index c0902414d277..ac4aaa2bda42 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterAlignmentTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterAlignmentTest.java @@ -350,7 +350,7 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest { public void testChainedMethodCalls_WithChopDownIfLongOption() throws Exception { getSettings().ALIGN_MULTILINE_CHAINED_METHODS = true; getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; // it's equal to "Chop down if long" - getSettings().getRootSettings().RIGHT_MARGIN = 50; + getSettings().RIGHT_MARGIN = 50; String before = "a.current.current.getThis().getThis().getThis().getThis().getThis();"; doMethodTest( @@ -362,14 +362,14 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest { " .getThis();" ); - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; doMethodTest(before, before); } public void testChainedMethodCalls_WithWrapIfNeededOption() throws Exception { getSettings().ALIGN_MULTILINE_CHAINED_METHODS = false; getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; - getSettings().getRootSettings().RIGHT_MARGIN = 50; + getSettings().RIGHT_MARGIN = 50; String before = "a.current.current.getThis().getThis().getThis().getThis();"; @@ -387,7 +387,7 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest { " .getThis().getThis();" ); - getSettings().getRootSettings().RIGHT_MARGIN = 75; + getSettings().RIGHT_MARGIN = 75; doMethodTest(before, before); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterBracesTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterBracesTest.java index 52dc555c981b..582fc3a81a6a 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterBracesTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterBracesTest.java @@ -158,7 +158,7 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest { public void testSimpleMethodsInOneLineEvenIfExceedsRightMargin() { getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; - getSettings().getRootSettings().RIGHT_MARGIN = 90; + getSettings().RIGHT_MARGIN = 90; String text = "public class Repr2 {\n" + " public void start() { System.out.println(\"kfjsdkfjsdkfjskdjfslkdjfklsdjfklsdjfksjdfkljsdkfjsd!\"); }\n" + "}"; @@ -242,4 +242,51 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest { doMethodTest(singleLine, multiLine); doMethodTest(multiLine, multiLine); } + + public void testMethodBraceOnNextLineIfWrapped() { + getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED; + getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; + getSettings().RIGHT_MARGIN = 50; + doClassTest( + "public static void main(int state, int column, int width, int rate) {\n" + + "}\n", + "public static void main(int state, int column,\n" + + " int width, int rate)\n" + + "{\n" + + "}\n" + ); + } + + public void testIDEA127110() { + getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true; + getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED; + doMethodTest( + "if ( 1 > 2) {\n" + + "\n" + + "} else {\n" + + "\n" + + "}\n" + + "\n" + + "try {\n" + + "\n" + + "} catch ( Exception e) {\n" + + "\n" + + "} finally {\n" + + "\n" + + "}", + "if (1 > 2) {\n" + + "\n" + + "} else {\n" + + "\n" + + "}\n" + + "\n" + + "try {\n" + + "\n" + + "} catch (Exception e) {\n" + + "\n" + + "} finally {\n" + + "\n" + + "}" + ); + } } diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java index ed79f2f60bc6..5749fe80b549 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java @@ -17,6 +17,7 @@ package com.intellij.psi.formatter.java; import com.intellij.lang.java.JavaLanguage; import com.intellij.psi.codeStyle.CodeStyleManager; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; import org.jetbrains.annotations.NotNull; @@ -32,8 +33,9 @@ public class JavaFormatterInEditorTest extends LightPlatformCodeInsightTestCase public void testCaretPositionOnLongLineWrapping() throws IOException { // Inspired by IDEA-70242 - getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; - getCurrentCodeStyleSettings().RIGHT_MARGIN = 40; + CommonCodeStyleSettings javaCommonSettings = getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE); + javaCommonSettings.WRAP_LONG_LINES = true; + javaCommonSettings.RIGHT_MARGIN = 40; doTest( "import static java.util.concurrent.atomic.AtomicInteger.*;\n" + "\n" + diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java index c00db0fc77ad..0831f555fa29 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java @@ -15,6 +15,7 @@ */ package com.intellij.psi.formatter.java; +import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.fileTypes.StdFileTypes; @@ -664,7 +665,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testParametersAlignment() throws Exception { final CommonCodeStyleSettings settings = getSettings(); settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; - settings.getRootSettings().RIGHT_MARGIN = 140; + settings.RIGHT_MARGIN = 140; doTest(); } @@ -903,7 +904,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testBraceOnNewLineIfWrapped() throws Exception { getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED; - getSettings().getRootSettings().RIGHT_MARGIN = 35; + getSettings().RIGHT_MARGIN = 35; getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true; doTextTest("class Foo {\n" + @@ -928,7 +929,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testFirstArgumentWrapping() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 20; + getSettings().RIGHT_MARGIN = 20; getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(\n" + " 1);\n" + " }\n" + "}"); @@ -956,7 +957,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testAssertStatementWrapping() throws Exception { getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP; - getSettings().getRootSettings().RIGHT_MARGIN = 40; + getSettings().RIGHT_MARGIN = 40; final JavaPsiFacade facade = getJavaFacade(); final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel(); try { @@ -1001,7 +1002,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testAssertStatementWrapping2() throws Exception { getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP; getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; - getSettings().getRootSettings().RIGHT_MARGIN = 37; + getSettings().RIGHT_MARGIN = 37; final CommonCodeStyleSettings.IndentOptions options = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA); options.INDENT_SIZE = 2; @@ -1044,7 +1045,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void test() throws Exception { getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2; getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2; - getSettings().getRootSettings().RIGHT_MARGIN = 37; + getSettings().RIGHT_MARGIN = 37; getSettings().ALIGN_MULTILINE_EXTENDS_LIST = true; getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; @@ -1081,7 +1082,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testLBrace() throws Exception { getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE; - getSettings().getRootSettings().RIGHT_MARGIN = 14; + getSettings().RIGHT_MARGIN = 14; doTextTest("class Foo {\n" + " void foo() {\n" + " \n" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + "\n" + " }\n" + "}"); } @@ -1194,7 +1195,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testArrayInitializerWrapping() throws Exception { getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = false; - getSettings().getRootSettings().RIGHT_MARGIN = 37; + getSettings().RIGHT_MARGIN = 37; doTextTest("class Foo{\n" + " public int[] i = new int[]{1,2,3,4,5,6,7,8,9};\n" + @@ -1537,7 +1538,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { getSettings().KEEP_CONTROL_STATEMENT_IN_ONE_LINE = true; getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; getSettings().ELSE_ON_NEW_LINE = false; - getSettings().getRootSettings().RIGHT_MARGIN = 110; + getSettings().RIGHT_MARGIN = 110; getSettings().KEEP_LINE_BREAKS = false; doTextTest("class Foo {\n" + " void foo() {\n" + @@ -1698,7 +1699,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testDoNotWrapLBrace() throws IncorrectOperationException { getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE; - getSettings().getRootSettings().RIGHT_MARGIN = 66; + getSettings().RIGHT_MARGIN = 66; doTextTest("public class Test {\n" + " void foo(){\n" + " if (veryLongIdentifier1 == 1 && veryLongIdentifier2 == 2) {\n" + @@ -1718,7 +1719,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = true; getSettings().ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE = true; - getSettings().getRootSettings().RIGHT_MARGIN = 40; + getSettings().RIGHT_MARGIN = 40; doTextTest("class Foo {\n" + " int[] a = new int[]{1,2,0x0052,0x0053,0x0054,0x0054,0x0054};\n" + "}", "class Foo {\n" + " int[] a = new int[]{\n" + " 1, 2, 0x0052, 0x0053,\n" + @@ -1768,7 +1769,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testWrapExtendsList() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 50; + getSettings().RIGHT_MARGIN = 50; getSettings().EXTENDS_LIST_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; @@ -1779,7 +1780,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testWrapLongExpression() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true; doTextTest("class Foo {\n" + @@ -1797,7 +1798,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testDoNotWrapCallChainIfParametersWrapped() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 87; + getSettings().RIGHT_MARGIN = 87; getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; @@ -1831,7 +1832,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testRightMargin_2() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 65; + getSettings().RIGHT_MARGIN = 65; getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = true; getSettings().KEEP_LINE_BREAKS = false; @@ -1844,7 +1845,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } public void testRightMargin_3() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 65; + getSettings().RIGHT_MARGIN = 65; getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = false; getSettings().KEEP_LINE_BREAKS = false; @@ -1902,12 +1903,12 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testWrapParamsOnEveryItem() throws Exception { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()); - int oldMargin = codeStyleSettings.RIGHT_MARGIN; + int oldMargin = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE).RIGHT_MARGIN; boolean oldKeep = codeStyleSettings.KEEP_LINE_BREAKS; int oldWrap = codeStyleSettings.METHOD_PARAMETERS_WRAP; try { - codeStyleSettings.RIGHT_MARGIN = 80; + codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, 80); codeStyleSettings.KEEP_LINE_BREAKS = false; codeStyleSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; @@ -1932,7 +1933,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { "}"); } finally { - codeStyleSettings.RIGHT_MARGIN = oldMargin; + codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, oldMargin); codeStyleSettings.KEEP_LINE_BREAKS = oldKeep; codeStyleSettings.METHOD_PARAMETERS_WRAP = oldWrap; } @@ -1942,10 +1943,10 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { public void testCommentAfterDeclaration() throws Exception { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()); - int oldMargin = codeStyleSettings.RIGHT_MARGIN; + int oldMargin = codeStyleSettings.getDefaultRightMargin(); try { - codeStyleSettings.RIGHT_MARGIN = 20; + codeStyleSettings.setDefaultRightMargin(20); codeStyleSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doMethodTest( "int i=0; //comment comment", @@ -1955,7 +1956,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest { } finally { - codeStyleSettings.RIGHT_MARGIN = oldMargin; + codeStyleSettings.setDefaultRightMargin(oldMargin); } } @@ -2106,7 +2107,7 @@ public void testSCR260() throws Exception { public void testSCR479() throws Exception { final CommonCodeStyleSettings settings = getSettings(); - settings.getRootSettings().RIGHT_MARGIN = 80; + settings.RIGHT_MARGIN = 80; settings.TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doTextTest("public class Foo {\n" + " public static void main(String[] args) {\n" + @@ -2190,7 +2191,7 @@ public void testSCR260() throws Exception { } public void test1607() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 30; + getSettings().RIGHT_MARGIN = 30; getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE; getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; getSettings().ALIGN_MULTILINE_PARAMETERS = true; @@ -2271,7 +2272,7 @@ public void testSCR260() throws Exception { getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().PREFER_PARAMETERS_WRAP = true; @@ -2392,7 +2393,7 @@ public void testSCR260() throws Exception { } public void test1980() throws Exception { - getSettings().getRootSettings().RIGHT_MARGIN = 144; + getSettings().RIGHT_MARGIN = 144; getSettings().TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().ALIGN_MULTILINE_TERNARY_OPERATION = true; @@ -2523,7 +2524,7 @@ public void testSCR260() throws Exception { public void testSCRIDEA_4783() throws IncorrectOperationException { getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; doTextTest("class Foo{\n" + " void foo() {\n" + @@ -2655,7 +2656,7 @@ public void testSCR260() throws Exception { doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " while (true) foo();\n" + " }\n" + "}"); - getSettings().getRootSettings().RIGHT_MARGIN = 17; + getSettings().RIGHT_MARGIN = 17; doTextTest("class Foo {\n" + " void foo() {\n" + " if (a) foo();\n" + " else bar();\n" + " }\n" + "}", "class Foo {\n" + @@ -2667,7 +2668,7 @@ public void testSCR260() throws Exception { " }\n" + "}"); - getSettings().getRootSettings().RIGHT_MARGIN = 30; + getSettings().RIGHT_MARGIN = 30; doTextTest("class Foo {\n" + " void foo() {\n" + " for (int i = 0; i < 10; i++) foo();\n" + " }\n" + "}", "class Foo {\n" + @@ -2677,12 +2678,12 @@ public void testSCR260() throws Exception { " }\n" + "}"); - getSettings().getRootSettings().RIGHT_MARGIN = 32; + getSettings().RIGHT_MARGIN = 32; doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " for (int var : vars)\n" + " foo();\n" + " }\n" + "}"); - getSettings().getRootSettings().RIGHT_MARGIN = 12; + getSettings().RIGHT_MARGIN = 12; doTextTest("class Foo {\n" + " void foo() {\n" + " do foo(); while (true);\n" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " do\n" + @@ -2691,7 +2692,7 @@ public void testSCR260() throws Exception { " }\n" + "}"); - getSettings().getRootSettings().RIGHT_MARGIN = 23; + getSettings().RIGHT_MARGIN = 23; doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " while (true)\n" + " foo();\n" + " }\n" + "}"); @@ -2807,7 +2808,7 @@ public void testSCR260() throws Exception { public void testIDEADEV_12836() throws IncorrectOperationException { getSettings().SPECIAL_ELSE_IF_TREATMENT = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; doTextTest("class Foo {\n" + "void foo(){\n" + "if (true){\n" + @@ -2886,7 +2887,7 @@ public void testSCR260() throws Exception { public void testIDEADEV_23551() throws IncorrectOperationException { getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; - getSettings().getRootSettings().RIGHT_MARGIN = 60; + getSettings().RIGHT_MARGIN = 60; doTextTest("public class Wrapping {\n" + "public static void sample() {\n" + "System.out.println(\".\" + File.separator + \"..\" + File.separator + \"some-directory-name\" + File.separator + \"more-file-name\");\n" + diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java index 512a7ef3c158..c06370b06743 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java @@ -32,7 +32,7 @@ import java.util.Calendar; public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { @SuppressWarnings("SpellCheckingInspection") public void testWrappingAnnotationArrayParameters() { - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doTextTest( "@AttributeOverrides( { @AttributeOverride(name = \"id\", column = @Column(name = \"recovery_id\"))," + @@ -64,7 +64,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testAnnotationParamValueExceedingRightMargin() { // Inspired by IDEA-18051 - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; doTextTest( "package formatting;\n" + "\n" + @@ -128,7 +128,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testEnumConstantsWrapping() { // Inspired by IDEA-54667 getSettings().ENUM_CONSTANTS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; // Don't expect the constants to be placed on new line. doTextTest( @@ -177,8 +177,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testWrapCompoundStringLiteralThatEndsAtRightMargin() { // Inspired by IDEA-82398 - getSettings().getRootSettings().RIGHT_MARGIN = 30; - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 30; + getSettings().WRAP_LONG_LINES = true; final String text = "class Test {\n" + " String s = \"first line \" +\n" + @@ -189,8 +189,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testWrapLongLine() { // Inspired by IDEA-55782 - getSettings().getRootSettings().RIGHT_MARGIN = 50; - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 50; + getSettings().WRAP_LONG_LINES = true; doTextTest( "class TestClass {\n" + @@ -218,8 +218,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testWrapLongLineWithTabs() { // Inspired by IDEA-55782 - getSettings().getRootSettings().RIGHT_MARGIN = 20; - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 20; + getSettings().WRAP_LONG_LINES = true; getIndentOptions().USE_TAB_CHARACTER = true; getIndentOptions().TAB_SIZE = 4; @@ -236,8 +236,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testWrapLongLineWithSelection() { // Inspired by IDEA-55782 - getSettings().getRootSettings().RIGHT_MARGIN = 20; - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 20; + getSettings().WRAP_LONG_LINES = true; String initial = "class TestClass {\n" + @@ -264,7 +264,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { @Bombed(user = "Roman Shevchenko", year = 2014, month = Calendar.MARCH, day = 14) public void testWrapMethodAnnotationBeforeParams() { // Inspired by IDEA-59536 - getSettings().getRootSettings().RIGHT_MARGIN = 90; + getSettings().RIGHT_MARGIN = 90; getSettings().METHOD_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; @@ -304,7 +304,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testResourceListWrap() { getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true; - getSettings().getRootSettings().RIGHT_MARGIN = 40; + getSettings().RIGHT_MARGIN = 40; getSettings().RESOURCE_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }", "try (MyResource r1 = null;\n" + @@ -323,7 +323,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testLineLongEnoughToExceedAfterFirstWrapping() { // Inspired by IDEA-103624 getSettings().WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 40; + getSettings().RIGHT_MARGIN = 40; getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doMethodTest( "test(1,\n" + @@ -344,7 +344,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testNoUnnecessaryWrappingIsPerformedForLongLine() { // Inspired by IDEA-103624 getSettings().WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 40; + getSettings().RIGHT_MARGIN = 40; getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; String text = "test(1,\n" + @@ -359,7 +359,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { public void testEnforceIndentMethodCallParamWrap() { getSettings().WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 140; + getSettings().RIGHT_MARGIN = 140; getSettings().PREFER_PARAMETERS_WRAP = true; getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; @@ -402,7 +402,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { @SuppressWarnings("SpellCheckingInspection") public void testDoNotWrapMethodsWithMethodCallAsParameters() { getSettings().WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 140; + getSettings().RIGHT_MARGIN = 140; getSettings().PREFER_PARAMETERS_WRAP = true; getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true; diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java index a1819a263617..ad3ad822d83e 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java @@ -28,8 +28,8 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings; public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testRightMargin() throws Exception { - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 35;// | + getSettings().WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 35; doTextTest( "/** Here is one-line java-doc comment */" + "class Foo {\n" + @@ -44,9 +44,9 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { } public void testEA49739() throws Exception { - getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 35; - getSettings().getRootSettings().WRAP_COMMENTS = true; + getSettings().WRAP_LONG_LINES = true; + getSettings().RIGHT_MARGIN = 35; + getSettings().WRAP_COMMENTS = true; doTextTest("class A {\n" + " /**\n" + " * @return a is one line javadoc\n" + @@ -70,7 +70,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; getSettings().getRootSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true; - getSettings().getRootSettings().RIGHT_MARGIN = 35; + getSettings().RIGHT_MARGIN = 35; doTextTest( "/** Here is one-line java-doc comment */" + "class Foo {\n" + @@ -87,7 +87,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { // Inspired by IDEA-61895 getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().JD_PRESERVE_LINE_FEEDS = true; - getSettings().getRootSettings().RIGHT_MARGIN = 48; + getSettings().RIGHT_MARGIN = 48; doTextTest( "/**\n" + @@ -108,7 +108,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testSCR11296() throws Exception { final CommonCodeStyleSettings settings = getSettings(); - settings.getRootSettings().RIGHT_MARGIN = 50; + settings.RIGHT_MARGIN = 50; settings.getRootSettings().WRAP_COMMENTS = true; settings.getRootSettings().ENABLE_JAVADOC_FORMATTING = true; settings.getRootSettings().JD_P_AT_EMPTY_LINES = false; @@ -119,7 +119,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testSCR2632() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; getSettings().getRootSettings().WRAP_COMMENTS = true; - getSettings().getRootSettings().RIGHT_MARGIN = 20; + getSettings().RIGHT_MARGIN = 20; LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7); doTextTest("/**\n" + " * <p />\n" + " * Another paragraph of the description placed after blank line.\n" + " */\n" + "class A{}", @@ -137,7 +137,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testSCR2632_JDK8_LanguageLevel() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; getSettings().getRootSettings().WRAP_COMMENTS = true; - getSettings().getRootSettings().RIGHT_MARGIN = 20; + getSettings().RIGHT_MARGIN = 20; LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); doTextTest("/**\n" + " * <p />\n" + " * Another paragraph of the description placed after blank line.\n" + " */\n" + "class A{}", @@ -355,7 +355,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testReturnTagAlignment() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; @@ -383,7 +383,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testReturnTagAlignmentWithPreTagOnFirstLine() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; @@ -410,7 +410,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testSeeTagAlignment() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; @@ -437,7 +437,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testDummySinceTagAlignment() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; @@ -464,7 +464,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testDummyDeprecatedTagAlignment() throws Exception { getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true; - getSettings().getRootSettings().RIGHT_MARGIN = 80; + getSettings().RIGHT_MARGIN = 80; getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getSettings().getRootSettings().WRAP_COMMENTS = true; getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true; @@ -490,7 +490,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { } public void testJavadocFormattingIndependentOfMethodIndentation() { - getCurrentCodeStyleSettings().RIGHT_MARGIN = 50; + getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 50); getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true; getCurrentCodeStyleSettings().WRAP_COMMENTS = true; getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; @@ -529,7 +529,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { } public void testJavadocAlignmentForInnerClasses() { - getCurrentCodeStyleSettings().RIGHT_MARGIN = 40; + getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 40); getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true; getCurrentCodeStyleSettings().WRAP_COMMENTS = true; getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; @@ -579,7 +579,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { } public void testAlignmentWithNoTopClassMembersIndentation() { - getCurrentCodeStyleSettings().RIGHT_MARGIN = 40; + getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 40); getCurrentCodeStyleSettings().WRAP_COMMENTS = true; getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true; getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE).DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = true; @@ -655,7 +655,7 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest { public void testDoNotWrapLongLineCommentWithSpaceInStart() throws Exception { getSettings().KEEP_FIRST_COLUMN_COMMENT = true; getSettings().WRAP_LONG_LINES = true; - getSettings().getRootSettings().RIGHT_MARGIN = 200; + getSettings().RIGHT_MARGIN = 200; String before = "public class JiraIssue {\n" + "\n" + " public static void main(String[] args) {\n" + |