use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class PyTestCase method findQuickFixByClassInIntentions.
/**
* Searches for quickfix itetion by its class
*
* @param clazz quick fix class
* @param <T> quick fix class
* @return quick fix or null if nothing found
*/
@Nullable
public <T extends LocalQuickFix> T findQuickFixByClassInIntentions(@NotNull final Class<T> clazz) {
for (final IntentionAction action : myFixture.getAvailableIntentions()) {
if ((action instanceof QuickFixWrapper)) {
final QuickFixWrapper quickFixWrapper = (QuickFixWrapper) action;
final LocalQuickFix fix = quickFixWrapper.getFix();
if (clazz.isInstance(fix)) {
@SuppressWarnings("unchecked") final T result = (T) fix;
return result;
}
}
}
return null;
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class SpellingPopupActionGroup method extractActions.
private static void extractActions(List<HighlightInfo.IntentionActionDescriptor> descriptors, Map<Anchor, List<AnAction>> actions) {
for (HighlightInfo.IntentionActionDescriptor actionDescriptor : descriptors) {
IntentionAction action = actionDescriptor.getAction();
if (action instanceof QuickFixWrapper) {
QuickFixWrapper wrapper = (QuickFixWrapper) action;
LocalQuickFix localQuickFix = wrapper.getFix();
if (localQuickFix instanceof SpellCheckerQuickFix) {
SpellCheckerQuickFix spellCheckerQuickFix = (SpellCheckerQuickFix) localQuickFix;
Anchor anchor = spellCheckerQuickFix.getPopupActionAnchor();
SpellCheckerIntentionAction popupAction = new SpellCheckerIntentionAction(action);
List<AnAction> list = actions.get(anchor);
if (list != null) {
list.add(popupAction);
}
}
}
}
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class StaticPseudoFunctionalStyleMethodTest method doTest.
private void doTest() {
myFixture.configureByFile(getTestName(true) + "/test.java");
myFixture.enableInspections(new StaticPseudoFunctionalStyleMethodInspection());
boolean isQuickFixFound = false;
for (IntentionAction action : myFixture.getAvailableIntentions()) {
if (action instanceof QuickFixWrapper) {
final LocalQuickFix fix = ((QuickFixWrapper) action).getFix();
if (fix instanceof StaticPseudoFunctionalStyleMethodInspection.ReplacePseudoLambdaWithLambda) {
myFixture.launchAction(action);
isQuickFixFound = true;
break;
}
}
}
assertTrue("Quick fix isn't found", isQuickFixFound);
myFixture.checkResultByFile(getTestName(true) + "/test_after.java");
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class SuperClassHasFrequentlyUsedInheritorsInspectionTest method doTest.
private void doTest(final int expectedSize) {
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.enableInspections(SuperClassHasFrequentlyUsedInheritorsInspection.class);
final Set<Pair<String, Integer>> actualSet = new HashSet<Pair<String, Integer>>();
for (IntentionAction intentionAction : myFixture.getAvailableIntentions()) {
if (intentionAction instanceof QuickFixWrapper) {
ChangeSuperClassFix changeSuperClassFix = getQuickFixFromWrapper((QuickFixWrapper) intentionAction);
if (changeSuperClassFix != null) {
actualSet.add(Pair.create(changeSuperClassFix.getNewSuperClass().getQualifiedName(), changeSuperClassFix.getPercent()));
}
}
}
assertSize(expectedSize, actualSet);
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class IntentionListStep method getWeight.
private int getWeight(IntentionActionWithTextCaching action) {
IntentionAction a = action.getAction();
int group = getGroup(action);
if (a instanceof IntentionActionWrapper) {
a = ((IntentionActionWrapper) a).getDelegate();
}
if (a instanceof IntentionWrapper) {
a = ((IntentionWrapper) a).getAction();
}
if (a instanceof HighPriorityAction) {
return group + 3;
}
if (a instanceof LowPriorityAction) {
return group - 3;
}
if (a instanceof SuppressIntentionActionFromFix) {
if (((SuppressIntentionActionFromFix) a).isShouldBeAppliedToInjectionHost() == ThreeState.NO) {
return group - 1;
}
}
if (a instanceof QuickFixWrapper) {
final LocalQuickFix quickFix = ((QuickFixWrapper) a).getFix();
if (quickFix instanceof HighPriorityAction) {
return group + 3;
}
if (quickFix instanceof LowPriorityAction) {
return group - 3;
}
}
return group;
}
Aggregations