From d926c3cca3414d677cfe7f90e1162d0a8d22fcf2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 1 Jul 2015 00:21:44 +0300 Subject: [PATCH] Cleanup (highlighting tests unified) --- .../advHighlighting7/LambdaExpressions.java | 39 -------------- .../advHighlighting7/MethodReferences.java | 28 ---------- .../advHighlighting/LambdaExpressions.java | 23 +++++++++ .../advHighlighting/MethodReferences.java | 12 +++++ .../UsedMethodsByMethodReferences.java | 0 .../daemon/LightAdvHighlightingJdk7Test.java | 39 ++++---------- .../daemon/LightAdvHighlightingJdk9Test.java | 30 ++++------- .../lambda/LightAdvHighlightingJdk8Test.java | 51 +++++++++---------- 8 files changed, 80 insertions(+), 142 deletions(-) delete mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java delete mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MethodReferences.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/LambdaExpressions.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/MethodReferences.java rename java/java-tests/testData/codeInsight/daemonCodeAnalyzer/{advHighlighting7 => lambda/advHighlighting}/UsedMethodsByMethodReferences.java (100%) diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java deleted file mode 100644 index 2ab94e139476..000000000000 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.*; - -class C { - interface Simplest { - void m(); - } - void use(Simplest s) { } - - interface IntParser { - int parse(String s); - } - - void test() { - Simplest simplest = () -> { }; - use(() -> { }); - - IntParser intParser = (String s) -> Integer.parseInt(s); - } - - Runnable foo() { - return () -> { System.out.println("foo"); }; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MethodReferences.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MethodReferences.java deleted file mode 100644 index e69bfbd795d0..000000000000 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MethodReferences.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class C { - interface Simplest { - void m(); - } - void simplest() { } - void use(Simplest s) { } - - void test() { - Simplest simplest = this::simplest; - use(this::simplest); - } -} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/LambdaExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/LambdaExpressions.java new file mode 100644 index 000000000000..18d7ba367e2a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/LambdaExpressions.java @@ -0,0 +1,23 @@ +import java.util.*; + +class C { + interface Simplest { + void m(); + } + void use(Simplest s) { } + + interface IntParser { + int parse(String s); + } + + void test() { + Simplest simplest = () -> { }; + use(() -> { }); + + IntParser intParser = (String s) -> Integer.parseInt(s); + } + + Runnable foo() { + return () -> { System.out.println("foo"); }; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/MethodReferences.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/MethodReferences.java new file mode 100644 index 000000000000..0ee43f637742 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/MethodReferences.java @@ -0,0 +1,12 @@ +class C { + interface Simplest { + void m(); + } + void simplest() { } + void use(Simplest s) { } + + void test() { + Simplest simplest = this::simplest; + use(this::simplest); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UsedMethodsByMethodReferences.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/UsedMethodsByMethodReferences.java similarity index 100% rename from java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UsedMethodsByMethodReferences.java rename to java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting/UsedMethodsByMethodReferences.java 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 5637abf7215e..fbf93e65e232 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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.codeInsight.daemon; import com.intellij.ToolExtensionPoints; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase; @@ -45,34 +44,20 @@ import java.util.List; */ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting7"; + @Override protected void setUp() throws Exception { super.setUp(); - enableInspectionTool(new UnusedDeclarationInspection()); - } - - private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... classes) { + enableInspectionTools(new UnusedDeclarationInspection(), new UncheckedWarningLocalInspection(), new JavacQuirksInspection(), new RedundantCastInspection()); setLanguageLevel(LanguageLevel.JDK_1_7); IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), myTestRootDisposable); - enableInspectionTools(classes); + } + + private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... inspections) { + enableInspectionTools(inspections); doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } - private void doTest(boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos, Class... classes) { - enableInspectionTools(classes); - doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); - } - - @NotNull - @Override - protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{ - new UncheckedWarningLocalInspection(), - new JavacQuirksInspection(), - new RedundantCastInspection() - }; - } - public void testAllJava15Features() { doTest(false, false); } public void testEnumSyntheticMethods() { doTest(false, false); } public void testDuplicateAnnotations() { doTest(false, false); } @@ -158,9 +143,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testExtendsBound() { doTest(false, false); } public void testIDEA84533() { doTest(false, false); } public void testClassLiteral() { doTest(false, false); } - public void testMethodReferences() { doTest(false, true, false); } - public void testUsedMethodsByMethodReferences() { doTest(true, true, false); } - public void testLambdaExpressions() { doTest(false, true, false); } public void testUncheckedWarning() { doTest(true, false); } public void testUncheckedWarningIDEA59290() { doTest(true, false); } public void testUncheckedWarningIDEA70620() { doTest(true, false); } @@ -179,7 +161,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testAmbiguousMethodCallIDEA67669() { doTest(false, false); } public void testInstanceMemberNotAccessibleInStaticContext() { doTest(false, false); } public void testRejectedTypeParamsForConstructor() { doTest(false, false); } - public void testAnnotationArgs() throws Exception { doTest(false, false);} + public void testAnnotationArgs() { doTest(false, false);} public void testIDEA70890() { doTest(false, false); } public void testIDEA63731() { doTest(false, false); } public void testIDEA62056() { doTest(false, false); } @@ -188,8 +170,5 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testIDEA111450() { doTest(true, false); } public void testExternalizable() { doTest(true, false); } public void testAccessToStaticMethodsFromInterfaces() { doTest(true, false); } - - public void testUncheckedExtendedWarnings() throws Exception { - doTest(true, false); - } + public void testUncheckedExtendedWarnings() { doTest(true, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java index 0c4874791fec..912947d67459 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -15,41 +15,33 @@ */ package com.intellij.codeInsight.daemon; -import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; -import org.jetbrains.annotations.NotNull; - public class LightAdvHighlightingJdk9Test extends LightDaemonAnalyzerTestCase { private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting9"; + @Override protected void setUp() throws Exception { super.setUp(); - enableInspectionTool(new UnusedDeclarationInspection()); - } - - private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... classes) { + enableInspectionTools(new UnusedDeclarationInspection(), new UncheckedWarningLocalInspection(), new JavacQuirksInspection(), new RedundantCastInspection()); setLanguageLevel(LanguageLevel.JDK_1_9); - IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, getModule(), myTestRootDisposable); - enableInspectionTools(classes); - doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, getModule(), getTestRootDisposable()); } - @NotNull @Override - protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{ - new UncheckedWarningLocalInspection(), - new JavacQuirksInspection(), - new RedundantCastInspection() - }; + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk18(); + } + + private void doTest(boolean checkWarnings, boolean checkInfos) { + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } public void testSafeVarargsApplicability() { doTest(true, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java index d6428929a0d8..38e017cfcd6e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -16,44 +16,43 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; -import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.compiler.JavacQuirksInspection; +import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase { - @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting"; + private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/advHighlighting"; - @NotNull @Override - protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{ - new JavacQuirksInspection(), - }; - } - - public void testUnderscore() throws Exception { - doTest(); - } - - public void testFinalVariableMightNotHaveBeenInitializedInsideLambda() throws Exception { - doTest(); - } - - public void testStrictfpInsideInterface() throws Exception { - doTest(); - } - - private void doTest() { + protected void setUp() throws Exception { + super.setUp(); + enableInspectionTools(new JavacQuirksInspection()); + setLanguageLevel(LanguageLevel.JDK_1_8); IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); - doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false); } @Override protected Sdk getProjectJDK() { return IdeaTestUtil.getMockJdk18(); } + + private void doTest() { + doTest(true, false, false); + } + + private void doTest(boolean warnings, boolean weakWarnings, boolean infos, InspectionProfileEntry... inspections) { + enableInspectionTools(inspections); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, weakWarnings, infos); + } + + public void testUnderscore() { doTest(); } + public void testFinalVariableMightNotHaveBeenInitializedInsideLambda() { doTest(); } + public void testStrictfpInsideInterface() { doTest(); } + public void testMethodReferences() { doTest(false, true, false); } + public void testUsedMethodsByMethodReferences() { doTest(true, true, false, new UnusedDeclarationInspection()); } + public void testLambdaExpressions() { doTest(false, true, false); } }