mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Improvements based on code review (IDEA-CR-38467, IDEA-CR-38658)
This commit is contained in:
@@ -64,7 +64,7 @@ public class DataManagerImpl extends DataManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getDataFromProvider(@NotNull final DataProvider provider, @NotNull String dataId, @Nullable Set<String> alreadyComputedIds) {
|
||||
public Object getDataFromProvider(@NotNull final DataProvider provider, @NotNull String dataId, @Nullable Set<String> alreadyComputedIds) {
|
||||
if (alreadyComputedIds != null && alreadyComputedIds.contains(dataId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+16
-3
@@ -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<UsageInfo> testFindUsages(@TestDataFile @NotNull String... fileNames);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user