use of com.intellij.codeInsight.intention.IntentionAction 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.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class RawTypeCanBeGenericTest method doTest.
private void doTest(String intentionName) {
myFixture.configureByFiles(getTestName(false) + ".java");
final IntentionAction singleIntention = myFixture.findSingleIntention(intentionName);
myFixture.launchAction(singleIntention);
myFixture.checkResultByFile(getTestName(false) + ".java", getTestName(false) + "_after.java", true);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class BlockMarkerCommentsTest method doTestQuickFix.
private void doTestQuickFix() {
final String testFileName = getTestName(false);
myFixture.enableInspections(new BlockMarkerCommentsInspection());
myFixture.configureByFile(testFileName + ".java");
final IntentionAction intentionAction = myFixture.findSingleIntention("Remove block marker comments");
assertNotNull(intentionAction);
myFixture.launchAction(intentionAction);
myFixture.checkResultByFile(testFileName + "_after.java", true);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class DaemonAnalyzerTestCase method findAndInvokeIntentionAction.
protected static void findAndInvokeIntentionAction(@NotNull Collection<HighlightInfo> infos, @NotNull String intentionActionName, @NotNull Editor editor, @NotNull PsiFile file) {
List<IntentionAction> actions = getIntentionActions(infos, editor, file);
IntentionAction intentionAction = LightQuickFixTestCase.findActionWithText(actions, intentionActionName);
if (intentionAction == null) {
fail(String.format("Could not find action by name %s.\n" + "Actions: [%s]\n" + "HighlightInfos: [%s]", intentionActionName, StringUtil.join(ContainerUtil.map(actions, c -> c.getText()), ", "), StringUtil.join(infos, ", ")));
}
CodeInsightTestFixtureImpl.invokeIntention(intentionAction, file, editor, intentionActionName);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class DefaultQuickFixProvider method registerPriorityActions.
private static void registerPriorityActions(@NotNull QuickFixActionRegistrar registrar, @NotNull TextRange fixRange, @NotNull PsiReferenceExpression refExpr) {
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(refExpr.getProject());
final Map<VariableKind, IntentionAction> map = new EnumMap<>(VariableKind.class);
map.put(VariableKind.FIELD, new CreateFieldFromUsageFix(refExpr));
map.put(VariableKind.STATIC_FINAL_FIELD, new CreateConstantFieldFromUsageFix(refExpr));
if (!refExpr.isQualified()) {
map.put(VariableKind.LOCAL_VARIABLE, new CreateLocalFromUsageFix(refExpr));
map.put(VariableKind.PARAMETER, new CreateParameterFromUsageFix(refExpr));
}
final VariableKind kind = getKind(styleManager, refExpr);
if (map.containsKey(kind)) {
map.put(kind, PriorityIntentionActionWrapper.highPriority(map.get(kind)));
}
for (IntentionAction action : map.values()) {
registrar.register(fixRange, action, null);
}
}
Aggregations