diff --git a/platform/platform-impl/src/com/intellij/ide/impl/DataManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/impl/DataManagerImpl.java index f04b8a413af5..79ec23370d43 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/DataManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/DataManagerImpl.java @@ -64,7 +64,7 @@ public class DataManagerImpl extends DataManager { } @Nullable - private Object getDataFromProvider(@NotNull final DataProvider provider, @NotNull String dataId, @Nullable Set alreadyComputedIds) { + public Object getDataFromProvider(@NotNull final DataProvider provider, @NotNull String dataId, @Nullable Set alreadyComputedIds) { if (alreadyComputedIds != null && alreadyComputedIds.contains(dataId)) { return null; } diff --git a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java index 274f474b03ca..66cfe33f08d6 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java +++ b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java @@ -3,7 +3,6 @@ package com.intellij.testFramework; import com.intellij.ide.DataManager; import com.intellij.ide.impl.DataManagerImpl; -import com.intellij.ide.impl.dataRules.GetDataRule; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataProvider; @@ -19,6 +18,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.util.HashSet; /** * @author peter @@ -32,7 +32,7 @@ public class TestDataProvider implements DataProvider, DataContext { this(project, false); } - public TestDataProvider(@NotNull Project project, boolean withRules) { + private TestDataProvider(@NotNull Project project, boolean withRules) { myProject = project; myWithRules = withRules; if (myWithRules) { @@ -43,6 +43,10 @@ public class TestDataProvider implements DataProvider, DataContext { } } + public static TestDataProvider withRules(Project project) { + return new TestDataProvider(project, true); + } + @Override public Object getData(@NotNull @NonNls String dataId) { if (myProject.isDisposed()) { @@ -81,10 +85,7 @@ public class TestDataProvider implements DataProvider, DataContext { } if (myWithRules) { - GetDataRule rule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(dataId); - if (rule != null) { - return rule.getData(myDelegateWithoutRules); - } + return ((DataManagerImpl)DataManager.getInstance()).getDataFromProvider(myDelegateWithoutRules, dataId, new HashSet<>()); } return null; } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java index b010105249cb..b3736a4bd9da 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java @@ -393,7 +393,8 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { void testCompletionVariants(@NotNull @TestDataFile String fileBefore, @NotNull String... items); /** - * Launches renaming refactoring on the PSI element at caret and checks the result. + * Opens the specified file in the editor, Launches renaming refactoring on the PSI element at caret and checks the result. + * For new tests, please use{@link #testRenameUsingHandler(String, String, String, String...)} instead of this method. * * @param fileBefore original file path. Use {@link #CARET_MARKER} to mark the element to rename. * @param fileAfter result file to be checked against. @@ -406,8 +407,8 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { @TestDataFile @NotNull String... additionalFiles); /** - * Launches renaming refactoring using the rename handler (using the high-level rename API, as opposed to retrieving the PSI element - * at caret and invoking the PSI rename on it) and checks the result. + * Opens the specified file in the editor, launches the rename refactoring using the rename handler (using the high-level + * rename API, as opposed to retrieving the PSI element at caret and invoking the PSI rename on it) and checks the result. * * @param fileBefore original file path. Use {@link #CARET_MARKER} to mark the element to rename. * @param fileAfter result file to be checked against. @@ -419,10 +420,22 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { @NotNull String newName, @TestDataFile @NotNull String... additionalFiles); + /** + * Launches the rename refactoring on the PSI element at caret and checks the result. For new tests, please use + * {@link #testRenameUsingHandler(String, String)} instead of this method. + */ void testRename(@NotNull @TestDataFile String fileAfter, @NotNull String newName); + /** + * launches the rename refactoring using the rename handler (using the high-level rename API, as opposed to + * retrieving the PSI element at caret and invoking the PSI rename on it) and checks the result. + */ void testRenameUsingHandler(@NotNull @TestDataFile String fileAfter, @NotNull String newName); + /** + * Invokes the Find Usages handler for the PSI element at caret and returns the usages returned by it. + * For new tests, please use {@link #testFindUsagesUsingAction} instead of this method. + */ @NotNull Collection testFindUsages(@TestDataFile @NotNull String... fileNames);