diff --git a/java/openapi/src/com/intellij/codeInsight/package-info.java b/java/openapi/src/com/intellij/codeInsight/package-info.java new file mode 100644 index 000000000000..467dcf9f421b --- /dev/null +++ b/java/openapi/src/com/intellij/codeInsight/package-info.java @@ -0,0 +1,8 @@ +// Copyright 2000-2025 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. +/** + * Provides interfaces for working with highlighting in standard IDE editors, interfaces + * and classes for defining intention actions and additional functionality related to background + * code analysis in the IDE. + * @see Code Insight (IntelliJ Platform Docs) + */ +package com.intellij.codeInsight; diff --git a/java/openapi/src/com/intellij/codeInsight/package.html b/java/openapi/src/com/intellij/codeInsight/package.html deleted file mode 100644 index b8d21861c132..000000000000 --- a/java/openapi/src/com/intellij/codeInsight/package.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -
-Provides interfaces for working with highlighting in standard IDEA editors, interfaces -and classes for defining intention actions and additional functionality related to background -code analysis in IDEA. - diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java index 1566cfa297ca..a73a75ef7c19 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java @@ -19,6 +19,19 @@ import org.jetbrains.annotations.NotNull; import java.io.File; +/** + * A JUnit 3-compatible {@link UsefulTestCase} which is based around a {@link JavaCodeInsightTestFixture}. + *+ * This class is similar to {@link LightJavaCodeInsightFixtureTestCase}, but with some differences: + *
+ * This class is similar to {@link JavaCodeInsightFixtureTestCase}, but with some differences: + *
+ * For examples, see {@link com.intellij.testFramework.junit5.showcase}. + *
+ * This package is a successor to {@link com.intellij.testFramework}.
+ */
+package com.intellij.testFramework.junit5;
diff --git a/platform/testFramework/src/com/intellij/testFramework/FileBasedTestCaseHelper.java b/platform/testFramework/src/com/intellij/testFramework/FileBasedTestCaseHelper.java
index b217de76ddbc..bd78b72c5567 100644
--- a/platform/testFramework/src/com/intellij/testFramework/FileBasedTestCaseHelper.java
+++ b/platform/testFramework/src/com/intellij/testFramework/FileBasedTestCaseHelper.java
@@ -5,24 +5,47 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
- * Should be implemented by a test together with annotation @RunWith(com.intellij.testFramework.Parameterized.class)
- * in order to get test run on all test data files located in directory. The desired directory could be configured
- * whether by implementing {@link FileBasedTestCaseHelperEx#getRelativeBasePath()} or by annotating test case
- * with {@link TestDataPath} (annotation would enable additional test assistance support, e.g.
- * navigation from test data to test class/method as well as starting tests right from test data files).
- *
- * BTW @RunWith works also on abstract super classes.
+ * Should be implemented by a test class together with the annotation {@code @RunWith(com.intellij.testFramework.Parameterized.class)}
+ * in order to get test run on all test data files located in directory.
+ *
+ * The desired directory can be configured by implementing + * {@link FileBasedTestCaseHelperEx#getRelativeBasePath()} + * or by annotating the test case class with {@link TestDataPath}. + * Annotating with {@link TestDataPath} enables additional test assistance support, like: + *
+ * Output: {@code null} + *
+ * Output: {@code MethodCanBeStatic.java} + * + * @return the "core part" of the file name if the file is an "after" file, or null otherwise */ - @Nullable - String getFileSuffix(@NotNull String fileName); + @Nullable String getFileSuffix(@NotNull String fileName); /** - * @return for 'after' files should return core file name or null otherwise + *
+ * Output: {@code MethodCanBeStatic.java} + *
+ * Output: {@code null} + * + * @return the "core part" of the file name if the file is an "after" file, or null otherwise */ default @Nullable String getBaseName(@NotNull String fileAfterSuffix) { return null; diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 90aab2d945f1..f1fd0bb781aa 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -77,11 +77,15 @@ import static com.intellij.testFramework.common.TestEnvironmentKt.initializeTest import static org.junit.Assume.assumeTrue; /** - * This class is compatible with both JUnit 3 and JUnit 4, - * but not JUnit 5 (see the module intellij.platform.testFramework.junit5 instead). + * This class is compatible with both JUnit 3 and JUnit 4, but not JUnit 5. *
- * To use JUnit 4, annotate your test subclass with {@code @RunWith(JUnit4.class)} or any other (like {@code Parametrized.class}), - * and you are all set. + * To use JUnit 3, make the name of your test methods start with {@code test}, as per the JUnit 3 convention. + *
+ * To use JUnit 4, annotate your test subclass with {@code @RunWith(JUnit4.class)} or any other runner (like {@code Parametrized.class}). + *
+ * For JUnit 5 support, + * see the {@code intellij.platform.testFramework.junit5} module in {@code community/platform/testFramework/junit5}. + *
@@ -90,9 +94,9 @@ import static org.junit.Assume.assumeTrue; *
* Don't define {@code @Rule}s calling {@linkplain #runBare()}, just subclassing this class (directly or indirectly) is enough. *
- * The execution order is the following: + *
+ * It is not tied to any specific test framework. + *
+ * Usually used to test code insight features such as inspections,
+ * intentions, code completion, highlighting, navigation, and refactorings in
+ * a headless-like IDE instance.
+ *
+ * @see Testing Overview
+ * @see Tests and Fixtures
+ * @see Testing Highlighting
* @see IdeaTestFixtureFactory#createCodeInsightFixture(IdeaProjectTestFixture)
*/
public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
@@ -88,7 +99,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
PsiFile getFile();
/**
- * @return the action context for current in-memory editor
+ * @return the action context for the current in-memory editor
*/
@RequiresReadLock
default ActionContext getActionContext() {
@@ -228,7 +239,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
/**
* Compares a file in the test project with a file in the testdata directory.
*
- * @param filePath path to file to be checked, relative to the source root of the test project.
+ * @param filePath path to the file to be checked, relative to the source root of the test project.
* @param expectedFile path to file to check against, relative to the testdata path.
* @param ignoreTrailingWhitespaces whether the comparison should ignore trailing whitespaces.
*/
@@ -244,7 +255,6 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
*/
void enableInspections(InspectionProfileEntry @NotNull ... inspections);
- @SuppressWarnings("unchecked")
void enableInspections(Class extends LocalInspectionTool> @NotNull ... inspections);
void enableInspections(@NotNull Collection
+ * To load the file in to the in-memory editor, use the {@code configure*} family of methods,
+ * for example {@link #configureByText(String, String)} or {@link #configureByFile(String)}}.
+ *
+ * Throws an exception if the file isn't loaded into the in-memory editor.
+ *
+ * @return highlighting duration in milliseconds
+ * @see ExpectedHighlightingData
+ */
long checkHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, boolean ignoreExtraHighlighting);
+ /**
+ * @see #checkHighlighting(boolean, boolean, boolean, boolean)
+ */
long checkHighlighting();
/**
- * Runs highlighting test for the given files.
+ * Loads files into the in-memory editor and tests highlighting for the first of them.
*
- * The same as {@link #testHighlighting(boolean, boolean, boolean, String...)} with {@code checkInfos=false}.
+ * This is essentially a shortcut for
+ * {@link #configureByFiles(String...)}
+ * followed by
+ * {@link #testHighlighting(boolean, boolean checkInfos, boolean, String...)}
+ * with {@code checkInfos=false}.
*
* @param filePaths the first file is tested only; the others are just copied along with the first.
* @return highlighting duration in milliseconds
@@ -321,7 +348,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
void testInspection(@NotNull String testDir, @NotNull InspectionToolWrapper, ?> toolWrapper, @NotNull VirtualFile sourceDir);
/**
- * @return all highlight infos for current file
+ * @return all highlight infos for the current file
*/
@NotNull
@Unmodifiable
@@ -371,7 +398,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
List
* Checks that lookup is shown, and it contains items with given lookup strings
*
- * @param items most probably will contain > 1 items
+ * @param items most probably will contain more than 1 item
*/
void testCompletionVariants(@NotNull @TestDataFile String fileBefore, String @NotNull ... items);
@@ -543,7 +570,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
/**
* Opens the specified file in the editor, places the caret and selection according to the markup,
- * launches the Find Usages action and returns the items displayed in the usage view.
+ * launches the Find Usages action, and returns the items displayed in the usage view.
*/
@NotNull
Collection
* Very close to {@link #renameElementAtCaret(String)} but uses handlers.
*
@@ -735,6 +765,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
/**
* Misnamed, actually it checks only parameter hints.
+ *
* @see #testInlays(Function, Predicate)
*/
void testInlays();
@@ -776,20 +807,20 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
* carets (places marked with {@link #CARET_MARKER} in file).
* Example:
*
+ * This framework is based around JUnit 3 and JUnit 4. Consider using a JUnit 5-based successor to this package – see {@link com.intellij.testFramework.junit5}.
+ */
+package com.intellij.testFramework;
- * PyC<caret> is IDE for Py<caret>
+ * PyC<caret> is an IDE for Py<caret>
*
* should be completed to
*
- * PyCharm is IDE for Python
+ * PyCharm is an IDE for Python
*
* Actually, it works just like {@link #completeBasic()} but supports
- * several {@link #CARET_MARKER}.
+ * several {@link #CARET_MARKER}s.
*
* @param charToTypeIfOnlyOneOrNoCompletion this char will be typed when the completion performed automatically.
* It is a legacy, consider providing it as {@code null} to avoid typing.
- * @param charToTypeIfMultipleCompletions this char will be typed in case of multiple completion variants.
- * It could be used to complete the suggestion with {@code '\t'} for example.
- * Provide {@code null} to avoid typing.
+ * @param charToTypeIfMultipleCompletions this char will be typed in case of multiple completion variants.
+ * It could be used to complete the suggestion with {@code '\t'} for example.
+ * Provide {@code null} to avoid typing.
* @return list of all completion elements just like in {@link #completeBasic()}
* @see #completeBasic()
*/
@@ -852,7 +883,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
/**
* @return Disposable for the corresponding project fixture.
* It's disposed earlier than {@link UsefulTestCase#getTestRootDisposable()} and can be useful
- * e.g. for avoiding library virtual pointers leaks: {@code PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), ...)}
+ * e.g., for avoiding library virtual pointers leaks: {@code PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), ...)}
*/
default @NotNull Disposable getProjectDisposable() {
return ((ProjectEx)getProject()).getEarlyDisposable();
diff --git a/platform/testFramework/src/com/intellij/testFramework/package-info.java b/platform/testFramework/src/com/intellij/testFramework/package-info.java
new file mode 100644
index 000000000000..fd5aa0e42518
--- /dev/null
+++ b/platform/testFramework/src/com/intellij/testFramework/package-info.java
@@ -0,0 +1,8 @@
+// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
+
+/**
+ * Provides a test framework for writing tests which use IDE projects, PSI and other services.
+ *