Search in sources :

Example 1 with CleanupInspectionIntention

use of com.intellij.codeInspection.actions.CleanupInspectionIntention in project intellij-community by JetBrains.

the class GuavaInspectionTest method doTestAllFile.

private void doTestAllFile() {
    myFixture.configureByFile(getTestName(true) + ".java");
    myFixture.enableInspections(new GuavaInspection());
    for (HighlightInfo info : myFixture.doHighlighting()) if (GuavaInspection.PROBLEM_DESCRIPTION.equals(info.getDescription())) {
        final Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> marker = info.quickFixActionMarkers.get(0);
        final PsiElement someElement = myFixture.getFile().findElementAt(0);
        assertNotNull(someElement);
        final List<IntentionAction> options = marker.getFirst().getOptions(someElement, myFixture.getEditor());
        assertNotNull(options);
        boolean doBreak = false;
        for (IntentionAction option : options) {
            if (option instanceof CleanupInspectionIntention) {
                myFixture.launchAction(option);
                doBreak = true;
                break;
            }
        }
        if (doBreak) {
            break;
        }
    }
    myFixture.checkResultByFile(getTestName(true) + "_after.java");
}
Also used : GuavaInspection(com.intellij.refactoring.typeMigration.inspections.GuavaInspection) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) List(java.util.List) PsiElement(com.intellij.psi.PsiElement) CleanupInspectionIntention(com.intellij.codeInspection.actions.CleanupInspectionIntention) Pair(com.intellij.openapi.util.Pair)

Aggregations

HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 CleanupInspectionIntention (com.intellij.codeInspection.actions.CleanupInspectionIntention)1 Pair (com.intellij.openapi.util.Pair)1 PsiElement (com.intellij.psi.PsiElement)1 GuavaInspection (com.intellij.refactoring.typeMigration.inspections.GuavaInspection)1 List (java.util.List)1