diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferApplicableAnnotations.java b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferApplicableAnnotations.java index fe6080708ee9..0f6023f275e4 100644 --- a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferApplicableAnnotations.java +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferApplicableAnnotations.java @@ -1,2 +1,2 @@ -@T +@Tt @interface Foo { } diff --git a/java/java-tests/testData/codeInsight/javadocIG/documentationForJdkClassWithReferencesToClassesFromJavaLang.html b/java/java-tests/testData/codeInsight/javadocIG/documentationForJdkClassWithReferencesToClassesFromJavaLang.html index 8d5bd35d56f8..85fb52bfeab3 100644 --- a/java/java-tests/testData/codeInsight/javadocIG/documentationForJdkClassWithReferencesToClassesFromJavaLang.html +++ b/java/java-tests/testData/codeInsight/javadocIG/documentationForJdkClassWithReferencesToClassesFromJavaLang.html @@ -1,4 +1,4 @@ -
@Contract(pure = true) 
+
@Contract(pure = true) 
 public abstract boolean contains(
Object o
)
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains diff --git a/java/java-tests/testData/codeInsight/javadocIG/reflectConstructor.html b/java/java-tests/testData/codeInsight/javadocIG/reflectConstructor.html index cb51115626f6..4267b3a0a4f5 100644 --- a/java/java-tests/testData/codeInsight/javadocIG/reflectConstructor.html +++ b/java/java-tests/testData/codeInsight/javadocIG/reflectConstructor.html @@ -1,5 +1,5 @@
@CallerSensitive 
-@NotNull 
-@Contract(pure = true) 
+@NotNull 
+@Contract(pure = true) 
 public java.lang.reflect.Constructor<?>[] getDeclaredConstructors()
 throws SecurityException

Throws:

SecurityException

 < java 10 >
\ No newline at end of file diff --git a/java/java-tests/testData/codeInspection/bytecodeAnalysis/annotations/org/jetbrains/annotations/annotations.xml b/java/java-tests/testData/codeInspection/bytecodeAnalysis/annotations/org/jetbrains/annotations/annotations.xml new file mode 100644 index 000000000000..96bf3b56f610 --- /dev/null +++ b/java/java-tests/testData/codeInspection/bytecodeAnalysis/annotations/org/jetbrains/annotations/annotations.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java b/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java index 62900d029f06..176d7f4bcb81 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java @@ -12,12 +12,12 @@ public class MutabilityBasics { return Collections.emptyList(); } - @Contract(mutates = "param") + @Contract(mutates = "param") static > void sort(List collection) { Collections.sort(collection); } - @Contract(mutates = "param1") + @Contract(mutates = "param1") static > void addAll(Collection collection, List other) { sort(other); collection.addAll(other); @@ -33,7 +33,7 @@ public class MutabilityBasics { interface Point { int get(); - @Contract(mutates = "this") + @Contract(mutates = "this") void set(int x); @Contract(pure = true) diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/StreamCollector10Inlining.java b/java/java-tests/testData/inspection/dataFlow/fixture/StreamCollector10Inlining.java index a8cee7ee9da8..5c166fc0afe4 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/StreamCollector10Inlining.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/StreamCollector10Inlining.java @@ -1,5 +1,3 @@ -package java.util.stream; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -7,14 +5,6 @@ import java.util.*; import java.util.function.*; import java.util.stream.*; -// Mock -class Collectors { - public static native Collector> toList(); - public static native Collector> toUnmodifiableList(); - public static native Collector> toUnmodifiableSet(); - public static native Collector> toUnmodifiableMap(Function keyMapper, Function valueMapper); -} - public class StreamCollector10Inlining { @Nullable diff --git a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt index 5f492a770b1b..867a42fb5626 100644 --- a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt +++ b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt @@ -9,6 +9,7 @@ PsiJavaFileStub [org.jetbrains.annotations] PsiRefListStub[IMPLEMENTS_LIST:] PsiMethodStub[annotation value:java.lang.String default=""] PsiModifierListStub[mask=1025] + PsiAnnotationStub[@org.jetbrains.annotations.NonNls] PsiTypeParameterListStub PsiParameterListStub PsiRefListStub[THROWS_LIST:] diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/AddAnnotationFixTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/AddAnnotationFixTest.java index 6716e2fe9633..9a3c519de792 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/AddAnnotationFixTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/AddAnnotationFixTest.java @@ -77,6 +77,7 @@ public class AddAnnotationFixTest extends UsefulTestCase { javaCodeStyleSettings.USE_EXTERNAL_ANNOTATIONS = false; } }); + ModuleRootModificationUtil.updateModel(myFixture.getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } @Override diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/ExternalAnnotationsTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/ExternalAnnotationsTest.java index 95d69c4ab78f..a3a97c7d88b0 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/ExternalAnnotationsTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/ExternalAnnotationsTest.java @@ -40,6 +40,7 @@ public class ExternalAnnotationsTest extends UsefulTestCase { myFixture.setUp(); Module myModule = builder.getFixture().getModule(); ModuleRootModificationUtil.updateModel(myModule, model -> { + DefaultLightProjectDescriptor.addJetBrainsAnnotations(model); String contentUrl = VfsUtilCore.pathToUrl(myFixture.getTempDirPath()); model.addContentEntry(contentUrl).addSourceFolder(contentUrl + "/src", false); final JavaModuleExternalPaths extension = model.getModuleExtension(JavaModuleExternalPaths.class); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java index 04a076a40504..3ea60b714eab 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java @@ -45,6 +45,7 @@ public class NullableNotNullManagerTest extends LightJavaCodeInsightFixtureTestC super.configureModule(module, model, contentEntry); VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(JavaTestUtil.getJavaTestDataPath() + "/nullableAnnotations/"); + addJetBrainsAnnotations(model); MavenDependencyUtil.addFromMaven(model, "com.google.code.findbugs:jsr305:3.0.2"); // Library order is important PsiTestUtil.newLibrary("lib_2.0").classesRoot(file.findChild("lib_2.0")).addTo(model); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionOrderingTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionOrderingTest.java index 3c05879c9339..35e180a1c1de 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionOrderingTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionOrderingTest.java @@ -404,8 +404,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { @NeedsIndex.ForStandardLibrary public void testPreferApplicableAnnotations() { myFixture.addClass( - "\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.ANNOTATION_TYPE)\n@interface TMetaAnno {}\n\n@Target(ElementType.LOCAL_VARIABLE)\n@interface TLocalAnno {}"); - checkPreferredItems(0, "TMetaAnno", "Target", "TabLayoutPolicy", "TabPlacement"); + "\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.ANNOTATION_TYPE)\n@interface TtMetaAnno {}\n\n@Target(ElementType.LOCAL_VARIABLE)\n@interface TtLocalAnno {}"); + checkPreferredItems(0, "TtMetaAnno", "TtLocalAnno"); } @NeedsIndex.ForStandardLibrary diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionTest.java index 2a0a77c9799b..078489f8f43d 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/NormalCompletionTest.java @@ -1659,8 +1659,8 @@ public class NormalCompletionTest extends NormalCompletionTestCase { @NeedsIndex.SmartMode(reason = "JavaGenerateMemberCompletionContributor.fillCompletionVariants provides dialog option in smart mode only") public void testImplementViaOverrideCompletion() { configure(); - myFixture.assertPreferredCompletionItems(0, "Override", "Override/Implement methods...", "public void run"); - getLookup().setCurrentItem(getLookup().getItems().get(2)); + myFixture.assertPreferredCompletionItems(0, "Override", "OverrideOnly", "Override/Implement methods...", "MustBeInvokedByOverriders", "public void run"); + getLookup().setCurrentItem(getLookup().getItems().get(4)); myFixture.type('\n'); checkResult(); } @@ -1668,8 +1668,8 @@ public class NormalCompletionTest extends NormalCompletionTestCase { @NeedsIndex.SmartMode(reason = "JavaGenerateMemberCompletionContributor.fillCompletionVariants provides dialog option in smart mode only") public void testSuggestToOverrideMethodsWhenTypingOverrideAnnotation() { configure(); - myFixture.assertPreferredCompletionItems(0, "Override", "Override/Implement methods..."); - getLookup().setCurrentItem(getLookup().getItems().get(1)); + myFixture.assertPreferredCompletionItems(0, "Override", "OverrideOnly", "Override/Implement methods..."); + getLookup().setCurrentItem(getLookup().getItems().get(2)); myFixture.type('\n'); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); checkResult(); @@ -1678,8 +1678,8 @@ public class NormalCompletionTest extends NormalCompletionTestCase { @NeedsIndex.SmartMode(reason = "JavaGenerateMemberCompletionContributor.fillCompletionVariants provides dialog option in smart mode only") public void testSuggestToOverrideMethodsWhenTypingOverrideAnnotationBeforeMethod() { configure(); - myFixture.assertPreferredCompletionItems(0, "Override", "Override/Implement methods..."); - getLookup().setCurrentItem(getLookup().getItems().get(1)); + myFixture.assertPreferredCompletionItems(0, "Override", "OverrideOnly", "Override/Implement methods..."); + getLookup().setCurrentItem(getLookup().getItems().get(2)); myFixture.type('\n'); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); checkResult(); @@ -1688,8 +1688,8 @@ public class NormalCompletionTest extends NormalCompletionTestCase { @NeedsIndex.SmartMode(reason = "JavaGenerateMemberCompletionContributor.fillCompletionVariants provides dialog option in smart mode only") public void testSuggestToOverrideMethodsInMulticaretMode() { configure(); - myFixture.assertPreferredCompletionItems(0, "Override", "Override/Implement methods..."); - getLookup().setCurrentItem(getLookup().getItems().get(1)); + myFixture.assertPreferredCompletionItems(0, "Override", "OverrideOnly", "Override/Implement methods..."); + getLookup().setCurrentItem(getLookup().getItems().get(2)); myFixture.type('\n'); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); checkResult(); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index f87a660e9bc1..bdddc3ffdd6a 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -28,6 +28,7 @@ import com.intellij.rt.execution.junit.FileComparisonFailure; import com.intellij.testFramework.DumbModeTestUtils; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PsiTestUtil; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.JavaVersion; import com.intellij.util.ui.UIUtil; @@ -55,6 +56,15 @@ public class JavaDocInfoGeneratorTest extends JavaCodeInsightTestCase { return IdeaTestUtil.getMockJdk(JavaVersion.compose(myJdkVersion)); } + @Override + protected void setUpModule() { + super.setUpModule(); + if (!getTestName(false).equals("HideNonDocumentedFlowAnnotations")) { + ModuleRootModificationUtil.updateModel( + myModule, model -> DefaultLightProjectDescriptor.addJetBrainsAnnotations(model)); + } + } + @Override protected @NotNull LanguageLevel getProjectLanguageLevel() { return LanguageLevel.HIGHEST; @@ -236,7 +246,7 @@ public class JavaDocInfoGeneratorTest extends JavaCodeInsightTestCase { } public void testHideNonDocumentedFlowAnnotations() { - Sdk sdk = removeAnnotationsJar(PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17())); + Sdk sdk = PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17()); WriteAction.runAndWait(() -> ProjectJdkTable.getInstance().addJdk(sdk, getTestRootDisposable())); ModuleRootModificationUtil.setModuleSdk(myModule, sdk); @@ -251,15 +261,6 @@ public class JavaDocInfoGeneratorTest extends JavaCodeInsightTestCase { assertFalse(doc, doc.contains("Flow")); } - private static Sdk removeAnnotationsJar(Sdk sdk) { - SdkModificator modificator = sdk.getSdkModificator(); - VirtualFile annotationsJar = ContainerUtil.find(modificator.getRoots(OrderRootType.CLASSES), r -> r.getName().contains("annotations")); - modificator.setName(modificator.getName() + "-" + annotationsJar.getPath()); - modificator.removeRoot(annotationsJar, OrderRootType.CLASSES); - modificator.commitChanges(); - return sdk; - } - public void testMatchingParameterNameFromParent() { configureByFile(); PsiClass psiClass = ((PsiJavaFile)myFile).getClasses()[1]; diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection10Test.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection10Test.java deleted file mode 100644 index 5a1d97e2faf6..000000000000 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection10Test.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.java.codeInspection; - -import com.intellij.JavaTestUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.LanguageLevelModuleExtension; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; -import com.intellij.testFramework.LightProjectDescriptor; -import com.intellij.testFramework.PsiTestUtil; -import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; -import org.jetbrains.annotations.NotNull; - -public class DataFlowInspection10Test extends DataFlowInspectionTestCase { - private static final DefaultLightProjectDescriptor PROJECT_DESCRIPTOR = new DefaultLightProjectDescriptor() { - @Override - public Sdk getSdk() { - return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk(LanguageLevel.JDK_10.toJavaVersion())); - } - - @Override - public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { - model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_10); - } - }; - - @NotNull - @Override - protected LightProjectDescriptor getProjectDescriptor() { - return PROJECT_DESCRIPTOR; - } - - @Override - protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; - } - - public void testStreamCollector10Inlining() { doTest(); } - - public void testAvoidWarningAtNotInferredType() { doTest();} - - public void testSameArguments() { doTest(); } -} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection11Test.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection11Test.java new file mode 100644 index 000000000000..497f7080c95b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection11Test.java @@ -0,0 +1,25 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.java.codeInspection; + +import com.intellij.JavaTestUtil; +import com.intellij.testFramework.LightProjectDescriptor; +import org.jetbrains.annotations.NotNull; + +public class DataFlowInspection11Test extends DataFlowInspectionTestCase { + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_11_ANNOTATED; + } + + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; + } + + public void testStreamCollector10Inlining() { doTest(); } + + public void testAvoidWarningAtNotInferredType() { doTest();} + + public void testSameArguments() { doTest(); } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTestSuite.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTestSuite.java index fd7b8ddace9d..bb508fba1de7 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTestSuite.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTestSuite.java @@ -16,7 +16,7 @@ import org.junit.platform.suite.api.Suite; DataFlowInspectionTest.class, DataFlowInspection8Test.class, DataFlowInspection9Test.class, - DataFlowInspection10Test.class, + DataFlowInspection11Test.class, DataFlowInspection16Test.class, DataFlowInspection20Test.class, DataFlowInspection21Test.class, diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java index 4fe5c1f9ab0f..6bfa6a4d07cc 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java @@ -55,6 +55,7 @@ public class BytecodeAnalysisIntegrationTest extends LightJavaCodeInsightFixture public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { super.configureModule(module, model, contentEntry); + addJetBrainsAnnotations(model); MavenDependencyUtil.addFromMaven(model, "org.apache.velocity:velocity:1.7"); MavenDependencyUtil.addFromMaven(model, "commons-collections:commons-collections:3.2.1"); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisResultsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisResultsHighlightingTest.java index 76cbeb33f831..b0993615fb36 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisResultsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/BytecodeAnalysisResultsHighlightingTest.java @@ -20,6 +20,7 @@ public class BytecodeAnalysisResultsHighlightingTest extends DataFlowInspectionT @Override public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { super.configureModule(module, model, contentEntry); + DefaultLightProjectDescriptor.addJetBrainsAnnotations(model); PsiTestUtil.addProjectLibrary(model, "velocity", IntelliJProjectConfiguration.getProjectLibraryClassesRootPaths("Velocity")); PsiTestUtil.addProjectLibrary(model, "commons-lang", IntelliJProjectConfiguration.getProjectLibraryClassesRootPaths("commons-lang3")); } diff --git a/java/java-tests/testSrc/com/intellij/java/psi/ClsStubBuilderTest.java b/java/java-tests/testSrc/com/intellij/java/psi/ClsStubBuilderTest.java index 52e390868d96..7a3199ba44e4 100644 --- a/java/java-tests/testSrc/com/intellij/java/psi/ClsStubBuilderTest.java +++ b/java/java-tests/testSrc/com/intellij/java/psi/ClsStubBuilderTest.java @@ -2,6 +2,7 @@ package com.intellij.java.psi; import com.intellij.JavaTestUtil; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.IoTestUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -11,11 +12,11 @@ import com.intellij.psi.impl.compiled.ClsFileImpl; import com.intellij.psi.stubs.PsiFileStub; import com.intellij.psi.stubs.StubBase; import com.intellij.testFramework.IdeaTestUtil; -import com.intellij.testFramework.LightIdeaTestCase; +import com.intellij.testFramework.LightJavaCodeInsightTestCase; import java.io.File; -public class ClsStubBuilderTest extends LightIdeaTestCase { +public class ClsStubBuilderTest extends LightJavaCodeInsightTestCase { public void testUtilList() { doClassTest("java.util.List"); } public void testNullable() { doClassTest("org.jetbrains.annotations.Nullable"); } public void testUtilCollections() { doClassTest("java.util.Collections"); } @@ -69,6 +70,11 @@ public class ClsStubBuilderTest extends LightIdeaTestCase { doTest(clsFile, getTestName(false) + ".txt"); } + @Override + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk17(); + } + private static void doTest(VirtualFile clsFile, String resultFileName) { try { PsiFileStub stub = ClsFileImpl.buildFileStub(clsFile, clsFile.contentsToByteArray()); diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/SafeDeleteTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/SafeDeleteTest.java index 8f4797546cc9..1299c5ee99a8 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/SafeDeleteTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/SafeDeleteTest.java @@ -9,6 +9,7 @@ import com.intellij.ide.scratch.ScratchRootType; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiClass; @@ -21,6 +22,7 @@ import com.intellij.refactoring.RefactoringSettings; import com.intellij.refactoring.safeDelete.SafeDeleteHandler; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PsiTestUtil; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -28,6 +30,12 @@ import org.jetbrains.jps.model.java.JavaSourceRootType; import org.jetbrains.jps.model.java.JpsJavaExtensionService; public class SafeDeleteTest extends MultiFileTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); + } + @NotNull @Override protected String getTestDataPath() { diff --git a/java/java-tests/testSrc/com/intellij/java/slicer/SliceBackwardTest.java b/java/java-tests/testSrc/com/intellij/java/slicer/SliceBackwardTest.java index 3f349a1fb2f4..68d2f48df22d 100644 --- a/java/java-tests/testSrc/com/intellij/java/slicer/SliceBackwardTest.java +++ b/java/java-tests/testSrc/com/intellij/java/slicer/SliceBackwardTest.java @@ -18,14 +18,12 @@ package com.intellij.java.slicer; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.execution.filters.ExceptionAnalysisProvider; +import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.slicer.*; -import com.intellij.testFramework.IdeaTestUtil; -import com.intellij.testFramework.PsiTestUtil; +import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -36,8 +34,8 @@ import java.util.Map; public class SliceBackwardTest extends SliceTestCase { @Override - protected Sdk getTestProjectJdk() { - return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk11()); + protected @NotNull LightProjectDescriptor getProjectDescriptor() { + return JAVA_17_ANNOTATED; } private void doTest() throws Exception { @@ -49,18 +47,18 @@ public class SliceBackwardTest extends SliceTestCase { } @Override - protected @NotNull LanguageLevel getProjectLanguageLevel() { - return LanguageLevel.JDK_16; + protected String getBasePath() { + return "/java/java-tests/testData/codeInsight/slice/backward/"; } private void doTest(@NotNull String filter, @NotNull String @NotNull... stack) throws Exception { - configureByFile("/codeInsight/slice/backward/"+getTestName(false)+".java"); + myFixture.configureByFile(getTestName(false)+".java"); Map sliceUsageName2Offset = SliceTestUtil.extractSliceOffsetsFromDocument(getEditor().getDocument()); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiElement element = SliceHandler.create(true).getExpressionAtCaret(getEditor(), getFile()); assertNotNull(element); SliceTestUtil.Node tree = SliceTestUtil.buildTree(element, sliceUsageName2Offset); - Collection errors = highlightErrors(); + Collection errors = myFixture.doHighlighting(HighlightSeverity.ERROR); assertEmpty(errors); SliceAnalysisParams params = new SliceAnalysisParams(); params.scope = new AnalysisScope(getProject()); diff --git a/java/java-tests/testSrc/com/intellij/java/slicer/SliceForwardTest.java b/java/java-tests/testSrc/com/intellij/java/slicer/SliceForwardTest.java index 960375c08dd2..cb61380737f0 100644 --- a/java/java-tests/testSrc/com/intellij/java/slicer/SliceForwardTest.java +++ b/java/java-tests/testSrc/com/intellij/java/slicer/SliceForwardTest.java @@ -17,6 +17,7 @@ package com.intellij.java.slicer; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.RangeMarker; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -26,14 +27,19 @@ import java.util.Collection; import java.util.Map; public class SliceForwardTest extends SliceTestCase { - private void dotest() throws Exception { - configureByFile("/codeInsight/slice/forward/"+getTestName(false)+".java"); + @Override + protected String getBasePath() { + return "/java/java-tests/testData/codeInsight/slice/forward/"; + } + + private void dotest() { + myFixture.configureByFile(getTestName(false)+".java"); Map sliceUsageName2Offset = SliceTestUtil.extractSliceOffsetsFromDocument(getEditor().getDocument()); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiElement element = SliceHandler.create(false).getExpressionAtCaret(getEditor(), getFile()); assertNotNull(element); SliceTestUtil.Node tree = SliceTestUtil.buildTree(element, sliceUsageName2Offset); - Collection errors = highlightErrors(); + Collection errors = myFixture.doHighlighting(HighlightSeverity.ERROR); assertEmpty(errors); SliceAnalysisParams params = new SliceAnalysisParams(); params.scope = new AnalysisScope(getProject()); @@ -42,14 +48,14 @@ public class SliceForwardTest extends SliceTestCase { SliceTestUtil.checkUsages(usage, tree); } - public void testSimple() throws Exception { dotest();} - public void testInterMethod() throws Exception { dotest();} - public void testParameters() throws Exception { dotest();} - public void testRequireNonNull() throws Exception { dotest();} - public void testAppend() throws Exception { dotest();} - public void testOverloadedMember() throws Exception { dotest();} - public void testOverloadedMember2() throws Exception { dotest();} - public void testOverloadedMember3() throws Exception { dotest();} - public void testOneInterfaceTwoImplementations() throws Exception { dotest();} - public void testOneInterfaceTwoImplementations2() throws Exception { dotest();} + public void testSimple() { dotest();} + public void testInterMethod() { dotest();} + public void testParameters() { dotest();} + public void testRequireNonNull() { dotest();} + public void testAppend() { dotest();} + public void testOverloadedMember() { dotest();} + public void testOverloadedMember2() { dotest();} + public void testOverloadedMember3() { dotest();} + public void testOneInterfaceTwoImplementations() { dotest();} + public void testOneInterfaceTwoImplementations2() { dotest();} } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/slicer/SliceTestCase.java b/java/java-tests/testSrc/com/intellij/java/slicer/SliceTestCase.java index 33bff16b2d79..d9c419fac0de 100644 --- a/java/java-tests/testSrc/com/intellij/java/slicer/SliceTestCase.java +++ b/java/java-tests/testSrc/com/intellij/java/slicer/SliceTestCase.java @@ -15,14 +15,13 @@ */ package com.intellij.java.slicer; -import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; -import com.intellij.testFramework.PsiTestUtil; +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; -public abstract class SliceTestCase extends DaemonAnalyzerTestCase { +public abstract class SliceTestCase extends LightJavaCodeInsightFixtureTestCase { @Override - protected Sdk getTestProjectJdk() { - return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17()); + protected @NotNull LightProjectDescriptor getProjectDescriptor() { + return JAVA_1_7_ANNOTATED; } } diff --git a/java/java-tests/testSrc/com/intellij/java/slicer/SliceTreeTest.java b/java/java-tests/testSrc/com/intellij/java/slicer/SliceTreeTest.java index 1c84daefd07e..9b87e52e2e02 100644 --- a/java/java-tests/testSrc/com/intellij/java/slicer/SliceTreeTest.java +++ b/java/java-tests/testSrc/com/intellij/java/slicer/SliceTreeTest.java @@ -3,6 +3,8 @@ package com.intellij.java.slicer; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; @@ -19,12 +21,17 @@ import org.jetbrains.annotations.NonNls; import java.util.*; public class SliceTreeTest extends SliceTestCase { - private SliceTreeStructure configureTree(@NonNls String name) throws Exception { - configureByFile("/codeInsight/slice/backward/"+ name +".java"); + @Override + protected String getBasePath() { + return "/java/java-tests/testData/codeInsight/slice/backward/"; + } + + private SliceTreeStructure configureTree(@NonNls String name) { + myFixture.configureByFile(name + ".java"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiElement element = SliceHandler.create(true).getExpressionAtCaret(getEditor(), getFile()); assertNotNull(element); - Collection errors = highlightErrors(); + Collection errors = myFixture.doHighlighting(HighlightSeverity.ERROR); assertEmpty(errors); SliceAnalysisParams params = new SliceAnalysisParams(); @@ -34,7 +41,7 @@ public class SliceTreeTest extends SliceTestCase { SliceUsage usage = LanguageSlicing.getProvider(element).createRootUsage(element, params); - ToolWindowHeadlessManagerImpl.MockToolWindow toolWindow = new ToolWindowHeadlessManagerImpl.MockToolWindow(myProject); + ToolWindowHeadlessManagerImpl.MockToolWindow toolWindow = new ToolWindowHeadlessManagerImpl.MockToolWindow(getProject()); SlicePanel panel = new SlicePanel(getProject(), true, new SliceRootNode(getProject(), new DuplicateMap(), usage), false, toolWindow) { @Override public boolean isAutoScroll() { @@ -68,7 +75,7 @@ public class SliceTreeTest extends SliceTestCase { } } - public void testTypingDoesNotInterfereWithDuplicates() throws Exception { + public void testTypingDoesNotInterfereWithDuplicates() { SliceTreeStructure treeStructure = configureTree("DupSlice"); SliceNode root = treeStructure.getRootElement(); List nodes = new ArrayList<>(); @@ -83,7 +90,7 @@ public class SliceTreeTest extends SliceTestCase { } } - type(" xx"); + myFixture.type(" xx"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); backspace(); backspace(); @@ -109,7 +116,11 @@ public class SliceTreeTest extends SliceTestCase { assertTrue(hasDups.isEmpty()); } - public void testLeafExpressionsAreEmptyInCaseOfInfinitelyExpandingTreeWithDuplicateNodes() throws Exception { + private void backspace() { + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE); + } + + public void testLeafExpressionsAreEmptyInCaseOfInfinitelyExpandingTreeWithDuplicateNodes() { SliceTreeStructure treeStructure = configureTree("Tuple"); SliceNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -118,7 +129,7 @@ public class SliceTreeTest extends SliceTestCase { assertEmpty(leaves); } - public void testLeafExpressionsSimple() throws Exception { + public void testLeafExpressionsSimple() { SliceTreeStructure treeStructure = configureTree("DupSlice"); SliceNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -129,7 +140,7 @@ public class SliceTreeTest extends SliceTestCase { assertEquals(1111111111, ((PsiLiteral)element).getValue()); } - public void testLeafExpressionsMoreComplex() throws Exception { + public void testLeafExpressionsMoreComplex() { SliceTreeStructure treeStructure = configureTree("Duplicate"); SliceNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -147,7 +158,7 @@ public class SliceTreeTest extends SliceTestCase { } @SuppressWarnings("ConstantConditions") - public void testGroupByValuesCorrectLeaves() throws Exception { + public void testGroupByValuesCorrectLeaves() { SliceTreeStructure treeStructure = configureTree("DuplicateLeaves"); SliceRootNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -192,7 +203,7 @@ public class SliceTreeTest extends SliceTestCase { assertEquals(child.getValue().getElement(), leaf); } - public void testNullness() throws Exception { + public void testNullness() { SliceTreeStructure treeStructure = configureTree("Nulls"); SliceRootNode root = treeStructure.getRootElement(); Map map = SliceNullnessAnalyzerBase.createMap(); @@ -292,7 +303,7 @@ public class SliceTreeTest extends SliceTestCase { assertEquals(dataExpected, dataActual); } - public void testDoubleNullness() throws Exception { + public void testDoubleNullness() { SliceTreeStructure treeStructure = configureTree("DoubleNulls"); SliceRootNode root = treeStructure.getRootElement(); Map map = SliceNullnessAnalyzerBase.createMap(); @@ -310,7 +321,7 @@ public class SliceTreeTest extends SliceTestCase { """); } - public void testGroupByLeavesWithLists() throws Exception { + public void testGroupByLeavesWithLists() { SliceTreeStructure treeStructure = configureTree(getTestName(false)); SliceRootNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -321,13 +332,13 @@ public class SliceTreeTest extends SliceTestCase { assertEquals(ContainerUtil.newHashSet("\"uuu\"", "\"xxx\""), names); } - public void testCollectionTrack() throws Exception { + public void testCollectionTrack() { Set names = groupByLeaves(); assertEquals(3, names.size()); assertEquals(ContainerUtil.newHashSet("\"uuu\"", "\"x\"", "\"y\""), names); } - private Set groupByLeaves() throws Exception { + private Set groupByLeaves() { SliceTreeStructure treeStructure = configureTree(getTestName(false)); SliceRootNode root = treeStructure.getRootElement(); SliceLeafAnalyzer analyzer = JavaSlicerAnalysisUtil.createLeafAnalyzer(); @@ -336,17 +347,17 @@ public class SliceTreeTest extends SliceTestCase { return ContainerUtil.map2Set(leaves, PsiElement::getText); } - public void testArrayCopyTrack() throws Exception { + public void testArrayCopyTrack() { Set names = groupByLeaves(); assertOrderedEquals(Collections.singletonList("\"x\""), assertOneElement(names)); } - public void testMapValuesTrack() throws Exception { + public void testMapValuesTrack() { Set names = groupByLeaves(); assertOrderedEquals(Collections.singletonList("\"y\""), assertOneElement(names)); } - public void testMapKeysTrack() throws Exception { + public void testMapKeysTrack() { Set names = groupByLeaves(); assertOrderedEquals(Collections.singletonList("\"x\""), assertOneElement(names)); } diff --git a/java/java-tests/testSrc/com/intellij/projectView/PackagesTreeStructureTest.java b/java/java-tests/testSrc/com/intellij/projectView/PackagesTreeStructureTest.java index ae27e96eb052..bb551353cf47 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/PackagesTreeStructureTest.java +++ b/java/java-tests/testSrc/com/intellij/projectView/PackagesTreeStructureTest.java @@ -100,10 +100,6 @@ public class PackagesTreeStructureTest extends TestSourceBasedTestCase { SwingUtilities.class -PsiPackage: META-INF MANIFEST.MF - MANIFEST.MF - -PsiPackage: org - +PsiPackage: intellij.lang.annotations - +PsiPackage: jetbrains.annotations LICENSE """ , 4); @@ -151,10 +147,6 @@ public class PackagesTreeStructureTest extends TestSourceBasedTestCase { SwingUtilities.class -PsiPackage: META-INF MANIFEST.MF - MANIFEST.MF - -PsiPackage: org - +PsiPackage: intellij.lang.annotations - +PsiPackage: jetbrains.annotations LICENSE """ , 3); diff --git a/java/java-tests/testSrc/com/siyeh/ig/fixes/PointlessBooleanExpressionFixTest.java b/java/java-tests/testSrc/com/siyeh/ig/fixes/PointlessBooleanExpressionFixTest.java index 1ae1e68de8d5..a51011826d78 100644 --- a/java/java-tests/testSrc/com/siyeh/ig/fixes/PointlessBooleanExpressionFixTest.java +++ b/java/java-tests/testSrc/com/siyeh/ig/fixes/PointlessBooleanExpressionFixTest.java @@ -4,6 +4,8 @@ package com.siyeh.ig.fixes; +import com.intellij.openapi.roots.ModuleRootModificationUtil; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.IGQuickFixesTestCase; import com.siyeh.ig.controlflow.PointlessBooleanExpressionInspection; @@ -17,6 +19,7 @@ public class PointlessBooleanExpressionFixTest extends IGQuickFixesTestCase { myFixture.enableInspections(inspection); myRelativePath = "pointlessboolean"; myDefaultHint = InspectionGadgetsBundle.message("constant.conditional.expression.simplify.quickfix"); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } public void testNegation() { doTest(); } diff --git a/java/java-tests/testSrc/com/siyeh/ig/fixes/dataflow/CreateNullBranchFixTest.java b/java/java-tests/testSrc/com/siyeh/ig/fixes/dataflow/CreateNullBranchFixTest.java index 3f73aa5c7d2f..7345e313937e 100644 --- a/java/java-tests/testSrc/com/siyeh/ig/fixes/dataflow/CreateNullBranchFixTest.java +++ b/java/java-tests/testSrc/com/siyeh/ig/fixes/dataflow/CreateNullBranchFixTest.java @@ -2,8 +2,10 @@ package com.siyeh.ig.fixes.dataflow; import com.intellij.codeInspection.dataFlow.DataFlowInspection; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.IGQuickFixesTestCase; @@ -14,6 +16,7 @@ public class CreateNullBranchFixTest extends IGQuickFixesTestCase { super.setUp(); myFixture.enableInspections(new DataFlowInspection()); myRelativePath = "dataflow/create_null_branch"; + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } @Override diff --git a/java/java-tests/testSrc/com/siyeh/ig/fixes/migration/IfCanBePatternSwitchFixTest.java b/java/java-tests/testSrc/com/siyeh/ig/fixes/migration/IfCanBePatternSwitchFixTest.java index 9b8008fb10ee..840948896b73 100644 --- a/java/java-tests/testSrc/com/siyeh/ig/fixes/migration/IfCanBePatternSwitchFixTest.java +++ b/java/java-tests/testSrc/com/siyeh/ig/fixes/migration/IfCanBePatternSwitchFixTest.java @@ -2,10 +2,12 @@ package com.siyeh.ig.fixes.migration; import com.intellij.codeInspection.CommonQuickFixBundle; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiKeyword; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.siyeh.ig.IGQuickFixesTestCase; import com.siyeh.ig.migration.IfCanBeSwitchInspection; @@ -18,6 +20,7 @@ public class IfCanBePatternSwitchFixTest extends IGQuickFixesTestCase { myFixture.enableInspections(inspection); myRelativePath = "migration/if_can_be_switch"; myDefaultHint = CommonQuickFixBundle.message("fix.replace.x.with.y", PsiKeyword.IF, PsiKeyword.SWITCH); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } @Override diff --git a/java/java-tests/testSrc/com/siyeh/ig/fixes/style/LambdaCanBeReplacedWithAnonymousFixTest.java b/java/java-tests/testSrc/com/siyeh/ig/fixes/style/LambdaCanBeReplacedWithAnonymousFixTest.java index d7ef9edbf8bb..dee5a0c0b9c6 100644 --- a/java/java-tests/testSrc/com/siyeh/ig/fixes/style/LambdaCanBeReplacedWithAnonymousFixTest.java +++ b/java/java-tests/testSrc/com/siyeh/ig/fixes/style/LambdaCanBeReplacedWithAnonymousFixTest.java @@ -17,8 +17,10 @@ package com.siyeh.ig.fixes.style; import com.intellij.application.options.CodeStyle; import com.intellij.lang.java.JavaLanguage; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.IGQuickFixesTestCase; import com.siyeh.ig.style.LambdaCanBeReplacedWithAnonymousInspection; @@ -29,6 +31,7 @@ public class LambdaCanBeReplacedWithAnonymousFixTest extends IGQuickFixesTestCas super.setUp(); myFixture.enableInspections(new LambdaCanBeReplacedWithAnonymousInspection()); myDefaultHint = InspectionGadgetsBundle.message("lambda.can.be.replaced.with.anonymous.quickfix"); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } public void testSimpleRunnable() { diff --git a/java/mockJDK-1.7/jre/lib/annotations.jar b/java/mockJDK-1.7/jre/lib/annotations.jar deleted file mode 100644 index cfbf21525bae..000000000000 Binary files a/java/mockJDK-1.7/jre/lib/annotations.jar and /dev/null differ diff --git a/java/mockJDK-1.7/jre/lib/annotations.jar_LICENSE b/java/mockJDK-1.7/jre/lib/annotations.jar_LICENSE deleted file mode 100644 index 4c4a741bfd61..000000000000 --- a/java/mockJDK-1.7/jre/lib/annotations.jar_LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2000-2016 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. diff --git a/java/mockJDK-1.8/jre/lib/annotations.jar b/java/mockJDK-1.8/jre/lib/annotations.jar deleted file mode 100644 index b78e2de180d4..000000000000 Binary files a/java/mockJDK-1.8/jre/lib/annotations.jar and /dev/null differ diff --git a/java/mockJDK-1.8/jre/lib/annotations.jar_LICENSE b/java/mockJDK-1.8/jre/lib/annotations.jar_LICENSE deleted file mode 100644 index 4c4a741bfd61..000000000000 --- a/java/mockJDK-1.8/jre/lib/annotations.jar_LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2000-2016 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. diff --git a/java/mockJDK-1.9/jre/lib/annotations.jar b/java/mockJDK-1.9/jre/lib/annotations.jar deleted file mode 100644 index b78e2de180d4..000000000000 Binary files a/java/mockJDK-1.9/jre/lib/annotations.jar and /dev/null differ diff --git a/java/mockJDK-11/jre/lib/annotations.jar b/java/mockJDK-11/jre/lib/annotations.jar deleted file mode 100644 index b78e2de180d4..000000000000 Binary files a/java/mockJDK-11/jre/lib/annotations.jar and /dev/null differ diff --git a/java/testFramework/src/com/intellij/testFramework/LightJavaCodeInsightTestCase.java b/java/testFramework/src/com/intellij/testFramework/LightJavaCodeInsightTestCase.java index c4ba6ddabee9..5435b5cf353d 100644 --- a/java/testFramework/src/com/intellij/testFramework/LightJavaCodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/LightJavaCodeInsightTestCase.java @@ -2,12 +2,16 @@ package com.intellij.testFramework; import com.intellij.openapi.Disposable; +import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleTypeId; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.util.Disposer; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.impl.JavaPsiFacadeEx; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import org.jetbrains.annotations.NotNull; import java.util.regex.Matcher; @@ -90,6 +94,16 @@ public abstract class LightJavaCodeInsightTestCase extends LightPlatformCodeInsi return IdeaTestUtil.getMockJdk18(); } + @Override + protected @NotNull LightProjectDescriptor getProjectDescriptor() { + return new SimpleLightProjectDescriptor(getModuleTypeId(), getProjectJDK()) { + @Override + protected void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { + DefaultLightProjectDescriptor.addJetBrainsAnnotations(model); + } + }; + } + @NotNull @Override protected String getModuleTypeId() { diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/DefaultLightProjectDescriptor.java b/java/testFramework/src/com/intellij/testFramework/fixtures/DefaultLightProjectDescriptor.java index 486eaf340cbd..5b6e3ecd456c 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/DefaultLightProjectDescriptor.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/DefaultLightProjectDescriptor.java @@ -32,7 +32,7 @@ import java.util.List; import java.util.function.Supplier; public class DefaultLightProjectDescriptor extends LightProjectDescriptor { - + private static final String JETBRAINS_ANNOTATIONS_COORDINATES = "org.jetbrains:annotations-java5:24.0.0"; private @Nullable Supplier customSdk; private final List mavenLibraries = new ArrayList<>(); @@ -80,6 +80,20 @@ public class DefaultLightProjectDescriptor extends LightProjectDescriptor { mavenLibraries.add(new RequiredLibrary(library, includeTransitive)); return this; } + + public DefaultLightProjectDescriptor withJetBrainsAnnotations() { + return withRepositoryLibrary(JETBRAINS_ANNOTATIONS_COORDINATES); + } + + /** + * Adds old non-type-use JetBrains annotations as a module dependency. + * Currently, many tests assume that this dependency is present. + * + * @param model model to modify + */ + public static void addJetBrainsAnnotations(@NotNull ModifiableRootModel model) { + MavenDependencyUtil.addFromMaven(model, JETBRAINS_ANNOTATIONS_COORDINATES); + } private static class RequiredLibrary { public final String mavenCoordinates; diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java index edb973aa08cb..4fd352782372 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java @@ -56,6 +56,7 @@ public abstract class LightJavaCodeInsightFixtureTestCase extends UsefulTestCase @Override public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLanguageLevel); + addJetBrainsAnnotations(model); } } @@ -78,6 +79,7 @@ public abstract class LightJavaCodeInsightFixtureTestCase extends UsefulTestCase public static final @NotNull LightProjectDescriptor JAVA_15 = new ProjectDescriptor(LanguageLevel.JDK_15); public static final @NotNull LightProjectDescriptor JAVA_16 = new ProjectDescriptor(LanguageLevel.JDK_16); public static final @NotNull LightProjectDescriptor JAVA_17 = new ProjectDescriptor(LanguageLevel.JDK_17); + public static final @NotNull LightProjectDescriptor JAVA_17_ANNOTATED = new ProjectDescriptor(LanguageLevel.JDK_17, true); public static final @NotNull LightProjectDescriptor JAVA_18 = new ProjectDescriptor(LanguageLevel.JDK_18); public static final @NotNull LightProjectDescriptor JAVA_19 = new ProjectDescriptor(LanguageLevel.JDK_19); public static final @NotNull LightProjectDescriptor JAVA_20 = new ProjectDescriptor(LanguageLevel.JDK_20_PREVIEW); diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/inspection/SSBasedInspectionTestCase.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/inspection/SSBasedInspectionTestCase.java index caf54a1b9e29..b36cfbe9fbfa 100644 --- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/inspection/SSBasedInspectionTestCase.java +++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/inspection/SSBasedInspectionTestCase.java @@ -13,6 +13,8 @@ import com.intellij.testFramework.fixtures.*; import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl; import org.jetbrains.annotations.NotNull; +import static com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase.JAVA_1_7; + /** * @author Bas Leijdekkers */ @@ -25,7 +27,7 @@ public abstract class SSBasedInspectionTestCase extends UsefulTestCase { super.setUp(); final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory(); final TestFixtureBuilder fixtureBuilder = - factory.createLightFixtureBuilder(new DefaultLightProjectDescriptor(), getTestName(false)); + factory.createLightFixtureBuilder(JAVA_1_7, getTestName(false)); final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture(); myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true)); myInspection = new SSBasedInspection(); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 1e635a1ad377..eee01c40d37b 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -36,10 +36,7 @@ import com.intellij.openapi.project.RootsChangeRescanningInfo; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.project.impl.ProjectImpl; import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.AnnotationOrderRootType; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.roots.impl.ProjectRootManagerImpl; import com.intellij.openapi.roots.impl.libraries.LibraryTableTracker; @@ -626,7 +623,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da ourProject = project; } - private static class SimpleLightProjectDescriptor extends LightProjectDescriptor { + protected static class SimpleLightProjectDescriptor extends LightProjectDescriptor { private final @NotNull String myModuleTypeId; private final @Nullable Sdk mySdk; diff --git a/plugins/IntelliLang/IntelliLang-tests/test/com/intellij/psi/impl/source/tree/injected/JavaInjectedFileChangesHandlerTest.kt b/plugins/IntelliLang/IntelliLang-tests/test/com/intellij/psi/impl/source/tree/injected/JavaInjectedFileChangesHandlerTest.kt index 9c177f3caafd..77be5a88211f 100644 --- a/plugins/IntelliLang/IntelliLang-tests/test/com/intellij/psi/impl/source/tree/injected/JavaInjectedFileChangesHandlerTest.kt +++ b/plugins/IntelliLang/IntelliLang-tests/test/com/intellij/psi/impl/source/tree/injected/JavaInjectedFileChangesHandlerTest.kt @@ -15,6 +15,7 @@ import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider +import com.intellij.openapi.roots.ModuleRootModificationUtil import com.intellij.openapi.ui.TestDialog import com.intellij.openapi.ui.TestDialogManager import com.intellij.openapi.util.TextRange @@ -23,6 +24,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.injection.Injectable import com.intellij.psi.util.parentOfType import com.intellij.testFramework.UsefulTestCase +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.InjectionTestFixture import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase import com.intellij.util.SmartList @@ -35,6 +37,11 @@ import org.jetbrains.uast.expressions.UStringConcatenationsFacade class JavaInjectedFileChangesHandlerTest : JavaCodeInsightFixtureTestCase() { + override fun setUp() { + super.setUp() + ModuleRootModificationUtil.updateModel(module, DefaultLightProjectDescriptor::addJetBrainsAnnotations) + } + fun `test edit multiline in fragment-editor`() { with(myFixture) { diff --git a/plugins/devkit/devkit-kotlin-tests/testSrc/org/jetbrains/idea/devkit/kotlin/navigation/KtPropertyKeyFoldingTest.kt b/plugins/devkit/devkit-kotlin-tests/testSrc/org/jetbrains/idea/devkit/kotlin/navigation/KtPropertyKeyFoldingTest.kt index cb168b3d116d..6a12c14f8898 100644 --- a/plugins/devkit/devkit-kotlin-tests/testSrc/org/jetbrains/idea/devkit/kotlin/navigation/KtPropertyKeyFoldingTest.kt +++ b/plugins/devkit/devkit-kotlin-tests/testSrc/org/jetbrains/idea/devkit/kotlin/navigation/KtPropertyKeyFoldingTest.kt @@ -2,13 +2,20 @@ package org.jetbrains.idea.devkit.kotlin.navigation import com.intellij.codeInsight.assertFolded +import com.intellij.openapi.roots.ModuleRootModificationUtil import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.builders.JavaModuleFixtureBuilder +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase import com.intellij.util.PathUtil class KtPropertyKeyFoldingTest : JavaCodeInsightFixtureTestCase() { + override fun setUp() { + super.setUp() + ModuleRootModificationUtil.updateModel(module, DefaultLightProjectDescriptor::addJetBrainsAnnotations) + } + override fun tuneFixture(moduleBuilder: JavaModuleFixtureBuilder<*>) { super.tuneFixture(moduleBuilder) moduleBuilder.addJdk(IdeaTestUtil.getMockJdk18Path().path) diff --git a/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/PluginModuleTestCase.java b/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/PluginModuleTestCase.java index b89b5241effb..c542a2cad34d 100644 --- a/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/PluginModuleTestCase.java +++ b/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/PluginModuleTestCase.java @@ -15,6 +15,9 @@ */ package org.jetbrains.idea.devkit.inspections; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.ContentEntry; +import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.TestDataFile; @@ -27,6 +30,11 @@ import org.jetbrains.idea.devkit.module.PluginModuleType; public abstract class PluginModuleTestCase extends LightJavaCodeInsightFixtureTestCase { private static final DefaultLightProjectDescriptor ourProjectDescriptor = new DefaultLightProjectDescriptor() { + @Override + public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { + super.configureModule(module, model, contentEntry); + addJetBrainsAnnotations(model); + } @NotNull @Override diff --git a/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/internal/UnsafeReturnStatementVisitorInspectionTestBase.java b/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/internal/UnsafeReturnStatementVisitorInspectionTestBase.java index 9961bcf41f83..cb0ab2e9f263 100644 --- a/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/internal/UnsafeReturnStatementVisitorInspectionTestBase.java +++ b/plugins/devkit/devkit-tests/testSrc/org/jetbrains/idea/devkit/inspections/internal/UnsafeReturnStatementVisitorInspectionTestBase.java @@ -1,10 +1,12 @@ // Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.idea.devkit.inspections.internal; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.util.Iconable; import com.intellij.psi.JavaRecursiveElementWalkingVisitor; import com.intellij.psi.PsiElement; import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; @@ -15,6 +17,7 @@ public abstract class UnsafeReturnStatementVisitorInspectionTestBase extends Jav protected void setUp() throws Exception { super.setUp(); myFixture.enableInspections(new UnsafeReturnStatementVisitorInspection()); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } @Override diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy index a87e77fcf0b5..cc54de54d672 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy @@ -1436,7 +1436,7 @@ import java.lang.annotation.Target; configure('@T @interface Foo {}') myFixture.completeBasic() - myFixture.assertPreferredCompletionItems 0, 'TMetaAnno', 'Target', 'TabLayoutPolicy', 'TabPlacement' + myFixture.assertPreferredCompletionItems 0, 'TMetaAnno', 'Target', 'TestOnly', 'TabLayoutPolicy', 'TabPlacement' } void testDiamondCompletion1() { diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java index 52b3fc0628bb..825e3268351c 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java @@ -6,6 +6,8 @@ import com.intellij.codeInspection.duplicateStringLiteral.DuplicateStringLiteral import com.intellij.java.i18n.JavaI18nBundle; import com.intellij.openapi.application.PluginPathManager; import com.intellij.openapi.application.impl.NonBlockingReadActionImpl; +import com.intellij.openapi.roots.ModuleRootModificationUtil; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; import java.util.List; @@ -17,6 +19,7 @@ public class DuplicateStringLiteralInspectionTest extends JavaCodeInsightFixture public void setUp() throws Exception { super.setUp(); myFixture.enableInspections(myInspection); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); } @Override diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java index c76190b23455..cffa81730139 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java @@ -17,9 +17,17 @@ package com.intellij.codeInspection.i18n; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.testFramework.JavaInspectionTestCase; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; public class InvalidPropertyKeyInspectionTest extends JavaInspectionTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + ModuleRootModificationUtil.updateModel(getModule(), DefaultLightProjectDescriptor::addJetBrainsAnnotations); + } + private void doTest() { LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(new InvalidPropertyKeyInspection()); doTest("invalidPropertyKey/" + getTestName(true), tool); diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/PropertyKeyFoldingTest.kt b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/PropertyKeyFoldingTest.kt index c06513e8c21c..151e89c1f1da 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/PropertyKeyFoldingTest.kt +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/PropertyKeyFoldingTest.kt @@ -2,13 +2,20 @@ package com.intellij.codeInspection.i18n import com.intellij.codeInsight.assertFolded +import com.intellij.openapi.roots.ModuleRootModificationUtil import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.builders.JavaModuleFixtureBuilder +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase import com.intellij.util.PathUtil class PropertyKeyFoldingTest : JavaCodeInsightFixtureTestCase() { + override fun setUp() { + super.setUp() + ModuleRootModificationUtil.updateModel(module, DefaultLightProjectDescriptor::addJetBrainsAnnotations) + } + override fun tuneFixture(moduleBuilder: JavaModuleFixtureBuilder<*>) { super.tuneFixture(moduleBuilder) moduleBuilder.addJdk(IdeaTestUtil.getMockJdk18Path().path) diff --git a/plugins/kotlin/completion/tests-shared/test/org/jetbrains/kotlin/idea/completion/test/AbstractJvmBasicCompletionTestBase.kt b/plugins/kotlin/completion/tests-shared/test/org/jetbrains/kotlin/idea/completion/test/AbstractJvmBasicCompletionTestBase.kt index 7d8d54f28975..f128db8d64fc 100644 --- a/plugins/kotlin/completion/tests-shared/test/org/jetbrains/kotlin/idea/completion/test/AbstractJvmBasicCompletionTestBase.kt +++ b/plugins/kotlin/completion/tests-shared/test/org/jetbrains/kotlin/idea/completion/test/AbstractJvmBasicCompletionTestBase.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.idea.completion.test import com.intellij.codeInsight.completion.CompletionType import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.roots.ModifiableRootModel import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.idea.test.KotlinJdkAndLibraryProjectDescriptor @@ -41,5 +42,9 @@ object KotlinJdkAndLibraryProjectDescriptorOnJdk8 : KotlinJdkAndLibraryProjectDe libraryFiles = KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance().libraryFiles, librarySourceFiles = KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance().librarySourceFiles, ) { + override fun addDefaultLibraries(model: ModifiableRootModel) { + // Skip adding JetBrains annotation for completion tests + } + override fun getSdk(): Sdk = IdeaTestUtil.getMockJdk18() } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/checkers/AbstractJavaAgainstKotlinCheckerTest.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/checkers/AbstractJavaAgainstKotlinCheckerTest.java index 8feb202bc734..13aa8053eae0 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/checkers/AbstractJavaAgainstKotlinCheckerTest.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/checkers/AbstractJavaAgainstKotlinCheckerTest.java @@ -7,9 +7,11 @@ import com.intellij.codeInspection.dataFlow.DataFlowInspection; import com.intellij.codeInspection.nullable.NullableStuffInspection; import com.intellij.openapi.module.Module; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; import com.siyeh.ig.bugs.StaticCallOnSubclassInspection; import com.siyeh.ig.bugs.StaticFieldReferenceOnSubclassInspection; import kotlin.collections.CollectionsKt; @@ -94,6 +96,8 @@ public abstract class AbstractJavaAgainstKotlinCheckerTest extends KotlinDaemonA protected Module createMainModule() throws IOException { Module module = super.createMainModule(); + ModuleRootModificationUtil.updateModel(module, DefaultLightProjectDescriptor::addJetBrainsAnnotations); + String configFileText = getConfigFileText(); if (configFileText == null) { return module; diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt index f4cc8be219ee..1eaf836a489b 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt @@ -90,7 +90,8 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur } - assertEquals("no library dependencies have to be recalculated",0, resolverTracker.librariesComputed.size) + assertEquals("no library dependencies have to be recalculated",0, + resolverTracker.librariesComputed.filterNot { it.name?.startsWith("org.jetbrains:annotations") ?: false }.size) } } diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt index 8a4aa760a30d..f3830351299f 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt @@ -59,7 +59,7 @@ abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/deco fun findTestLibraryRoot(module: Module): VirtualFile? { for (orderEntry in ModuleRootManager.getInstance(module).orderEntries) { - if (orderEntry is LibraryOrderEntry) { + if (orderEntry is LibraryOrderEntry && orderEntry.libraryName?.startsWith("org.jetbrains:annotations") != true) { return orderEntry.getRootFiles(OrderRootType.CLASSES)[0] } } diff --git a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java index aba15ee3c9a7..c4acb7762ddb 100644 --- a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java +++ b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java @@ -9,6 +9,8 @@ import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; +import com.intellij.testFramework.fixtures.MavenDependencyUtil; import org.jetbrains.annotations.NotNull; public class KotlinLightProjectDescriptor extends LightProjectDescriptor { @@ -30,9 +32,14 @@ public class KotlinLightProjectDescriptor extends LightProjectDescriptor { @Override public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { + addDefaultLibraries(model); configureModule(module, model); } + protected void addDefaultLibraries(@NotNull ModifiableRootModel model) { + DefaultLightProjectDescriptor.addJetBrainsAnnotations(model); + } + public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) { } } diff --git a/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/LombokTestUtil.java b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/LombokTestUtil.java index 663f8d03afda..bcd179ff3559 100644 --- a/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/LombokTestUtil.java +++ b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/LombokTestUtil.java @@ -19,6 +19,7 @@ public final class LombokTestUtil { public static final DefaultLightProjectDescriptor LOMBOK_DESCRIPTOR = new DefaultLightProjectDescriptor() { @Override public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { + DefaultLightProjectDescriptor.addJetBrainsAnnotations(model); MavenDependencyUtil.addFromMaven(model, LOMBOK_MAVEN_COORDINATES); MavenDependencyUtil.addFromMaven(model, JACKSON_MAVEN_COORDINATES); MavenDependencyUtil.addFromMaven(model, "com.google.guava:guava:27.0.1-jre");