getAllQuickFixes
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Tue, 2 Mar 2010 12:16:03 +0000 (15:16 +0300)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Tue, 2 Mar 2010 12:16:03 +0000 (15:16 +0300)
platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java

index 469ca5d8c8fa370684bd4721943714944a223a6a..9035ea177d7188b7f749c680e039cba4c308d15c 100644 (file)
@@ -33,7 +33,6 @@ import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiReference;
 import com.intellij.testFramework.TestDataFile;
-import com.intellij.testFramework.TestDataPath;
 import com.intellij.usageView.UsageInfo;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -173,15 +172,19 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
   PsiReference getReferenceAtCaretPositionWithAssertion(@NonNls String... filePaths) throws Exception;
 
   /**
-   * Collects available intentions in the whole file or at caret position if {@link #CARET_MARKER} presents.
+   * Collects available intentions at caret position.
    *
    * @param filePaths the first file is tested only; the others are just copied along with the first.
    * @return available intentions.
    * @throws Exception any exception.
+   * @see #CARET_MARKER
    */
   @NotNull
   List<IntentionAction> getAvailableIntentions(@NonNls String... filePaths) throws Exception;
 
+  @NotNull
+  List<IntentionAction> getAllQuickFixes(@NonNls String... filePaths) throws Exception;
+
   @NotNull
   List<IntentionAction> getAvailableIntentions() throws Exception;
 
index 84fba5db90805cadcd691912bb18900e9ca4549c..d0f5efb3aba4c0fd912f0fe39efc0982e3ff7bff 100644 (file)
@@ -393,8 +393,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
   @NotNull
   public List<IntentionAction> getAvailableIntentions(final String... filePaths) throws Exception {
 
-    final Project project = myProjectFixture.getProject();
-    return new WriteCommandAction<List<IntentionAction>>(project) {
+    return new WriteCommandAction<List<IntentionAction>>(myProjectFixture.getProject()) {
       protected void run(final Result<List<IntentionAction>> result) throws Exception {
         configureByFilesInner(filePaths);
         result.setResult(getAvailableIntentions());
@@ -402,6 +401,23 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
     }.execute().getResultObject();
   }
 
+  @NotNull
+  public List<IntentionAction> getAllQuickFixes(@NonNls final String... filePaths) {
+    return new WriteCommandAction<List<IntentionAction>>(myProjectFixture.getProject()) {
+      protected void run(final Result<List<IntentionAction>> result) throws Exception {
+        configureByFilesInner(filePaths);
+        List<HighlightInfo> infos = doHighlighting();
+        ArrayList<IntentionAction> actions = new ArrayList<IntentionAction>();
+        for (HighlightInfo info : infos) {
+          for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair : info.quickFixActionRanges) {
+            actions.add(pair.getFirst().getAction());
+          }
+        }
+        result.setResult(actions);
+      }
+    }.execute().getResultObject();
+  }
+
   @NotNull
   public List<IntentionAction> getAvailableIntentions() {
     doHighlighting();