mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use mock jdk 8 by default in InspectionTestCase
This commit is contained in:
@@ -23,7 +23,6 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.java15api.Java15APIUsageInspection;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
@@ -63,11 +62,6 @@ public class JavaAPIUsagesInspectionTest extends InspectionTestCase {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, JavaAPIUsagesInspectionTest.this::doTest);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
|
||||
//generate apiXXX.txt
|
||||
/*
|
||||
//todo exclude inheritors of ConcurrentMap#putIfAbsent
|
||||
|
||||
+3
-1
@@ -38,6 +38,7 @@ import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.source.PsiClassImpl;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.FileTreeAccessFilter;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -62,7 +63,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase {
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
return PsiTestUtil.addJdkAnnotations(super.getTestProjectSdk());
|
||||
// has to have JFrame and sources
|
||||
return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17());
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -17,6 +18,12 @@ public class RedundantCast15Test extends InspectionTestCase {
|
||||
ModuleRootModificationUtil.setModuleSdk(getModule(), getTestProjectSdk());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// in jdk 8 some casts are unnecessary
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
final LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(new RedundantCastInspection());
|
||||
doTest("redundantCast/generics/" + getTestName(false), toolWrapper, "java 1.5");
|
||||
|
||||
@@ -17,10 +17,6 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
public class RedundantCast18Test extends InspectionTestCase {
|
||||
@@ -35,11 +31,4 @@ public class RedundantCast18Test extends InspectionTestCase {
|
||||
public void testForeachValue() throws Exception { doTest(); }
|
||||
public void testConditional() throws Exception { doTest(); }
|
||||
public void testInferApplicabilityError() throws Exception { doTest(); }
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
return sdk;
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,6 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.unneededThrows.RedundantThrows;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
public class RedundantThrowTest extends InspectionTestCase {
|
||||
@@ -68,11 +64,4 @@ public class RedundantThrowTest extends InspectionTestCase {
|
||||
public void testThrownClausesInFunctionalExpressions() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
return sdk;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,6 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
public class UnusedReturnValueTest extends InspectionTestCase {
|
||||
@@ -47,13 +43,6 @@ public class UnusedReturnValueTest extends InspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk18();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
public void testSimpleSetter() throws Exception {
|
||||
try {
|
||||
myTool.IGNORE_BUILDER_PATTERN = true;
|
||||
|
||||
Binary file not shown.
@@ -234,8 +234,8 @@ public abstract class InspectionTestCase extends PsiTestCase {
|
||||
}
|
||||
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk18();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
package com.siyeh.igtest.naming.standard_variable_names;
|
||||
|
||||
import java.io.*;
|
||||
public class StandardVariableNames {
|
||||
|
||||
void bad() {
|
||||
@@ -21,9 +21,13 @@ public class StandardVariableNames {
|
||||
long l;
|
||||
String s, str;
|
||||
|
||||
new java.io.OutputStream() {
|
||||
new MyOutputStream() {
|
||||
// same as super
|
||||
public void write(int b) throws IOException {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
interface MyOutputStream {
|
||||
void write(int b) throws IOException;
|
||||
}
|
||||
+7
@@ -84,4 +84,11 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Standard variable names</problem_class>
|
||||
<description>Variable named <code>str</code> doesn't have type 'java.lang.String' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StandardVariableNames.java</file>
|
||||
<line>32</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Standard variable names</problem_class>
|
||||
<description>Variable named <code>b</code> doesn't have type 'byte' or 'java.lang.Byte' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+7
@@ -1,8 +1,15 @@
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class AssertWithSideEffectsInspectionTest extends IGInspectionTestCase {
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// uses SQL
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/bugs/assert_with_side_effects",
|
||||
|
||||
-12
@@ -15,24 +15,12 @@
|
||||
*/
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class FinalPrivateMethodInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/classlayout/final_private_method", new FinalPrivateMethodInspection());
|
||||
}
|
||||
|
||||
-11
@@ -1,9 +1,5 @@
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase {
|
||||
@@ -14,11 +10,4 @@ public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspe
|
||||
tool.ignoreJavaDoc = true;
|
||||
doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
return sdk;
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -1,14 +1,11 @@
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
|
||||
final LanguageLevel level = levelProjectExtension.getLanguageLevel();
|
||||
@@ -21,9 +18,4 @@ public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCas
|
||||
levelProjectExtension.setLanguageLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -15,9 +15,16 @@
|
||||
*/
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class UnnecessaryFinalOnLocalVariableOrParameterInspectionTest extends IGInspectionTestCase {
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// effectively final rules are different in jdk 8
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/style/unnecessary_final_on_local_variable_or_parameter",
|
||||
|
||||
+8
-1
@@ -1,14 +1,21 @@
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
private static final String BASE_DIR = "com/siyeh/igtest/style/";
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// uses awt
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
public void testFqnInJavadoc_Unnecessary_WhenFullyQualifyIfNotImported() throws Exception {
|
||||
doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fqn_javadoc_fully_qualify_if_not_imported", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED);
|
||||
}
|
||||
|
||||
-13
@@ -1,22 +1,9 @@
|
||||
package com.siyeh.ig.visibility;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class MethodOverloadsParentMethodInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/visibility/method_overloads_parent_method", new MethodOverloadsParentMethodInspection());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
final Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user