use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class RegisterExtensionFixProviderTest method testCreateExtensionPointMappingNoPluginId.
public void testCreateExtensionPointMappingNoPluginId() {
myFixture.testHighlighting("MyExtensionPoint.java", "extensionPointNoPluginId.xml", "ExtensionPoint.java");
IntentionAction intention = myFixture.findSingleIntention("Register extension");
myFixture.launchAction(intention);
myFixture.checkResultByFile("extensionPointNoPluginId.xml", "extensionPointNoPluginId_after.xml", true);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class RegisterExtensionFixProviderTest method testCreateExtensionPointQualifiedNameMapping.
public void testCreateExtensionPointQualifiedNameMapping() {
myFixture.testHighlighting("MyExtensionPoint.java", "extensionPointQualifiedName.xml", "ExtensionPoint.java");
IntentionAction intention = myFixture.findSingleIntention("Register extension");
myFixture.launchAction(intention);
myFixture.checkResultByFile("extensionPointQualifiedName.xml", "extensionPointQualifiedName_after.xml", true);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class UnsafeReturnStatementVisitorTest method testInsertVisitLambda.
public void testInsertVisitLambda() {
myFixture.addClass("package com.intellij.psi;\n" + "public interface PsiLambdaExpression{}");
myFixture.addClass("package com.intellij.psi;\n" + "public abstract class JavaRecursiveElementVisitor{}");
myFixture.addClass("package com.intellij.psi;\n" + "public interface PsiReturnStatement{}");
myFixture.addClass("package com.intellij.psi;\n" + "public interface PsiClass{}");
myFixture.configureByText(JavaFileType.INSTANCE, "import com.intellij.psi.*;\n" + "class Te<caret>st extends JavaRecursiveElementVisitor {\n" + " public void visitReturnStatement(PsiReturnStatement statement) {}\n" + " public void visitClass(PsiClass aClass) {}\n" + "}");
IntentionAction intention = myFixture.findSingleIntention("Insert visitLambdaExpression method");
myFixture.launchAction(intention);
myFixture.checkResult("import com.intellij.psi.*;\n" + "class Test extends JavaRecursiveElementVisitor {\n" + " public void visitReturnStatement(PsiReturnStatement statement) {}\n" + " public void visitClass(PsiClass aClass) {}\n" + "\n" + " public void visitLambdaExpression(PsiLambdaExpression expression) {\n" + " }\n" + "}");
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class LocalInspectionsPass method registerQuickFixes.
private static void registerQuickFixes(@NotNull LocalInspectionToolWrapper tool, @NotNull ProblemDescriptor descriptor, @NotNull HighlightInfo highlightInfo, @NotNull Set<Pair<TextRange, String>> emptyActionRegistered) {
final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
boolean needEmptyAction = true;
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null && fixes.length > 0) {
for (int k = 0; k < fixes.length; k++) {
if (fixes[k] != null) {
// prevent null fixes from var args
QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixWrapper.wrap(descriptor, k), key);
needEmptyAction = false;
}
}
}
HintAction hintAction = descriptor instanceof ProblemDescriptorImpl ? ((ProblemDescriptorImpl) descriptor).getHintAction() : null;
if (hintAction != null) {
QuickFixAction.registerQuickFixAction(highlightInfo, hintAction, key);
needEmptyAction = false;
}
if (((ProblemDescriptorBase) descriptor).getEnforcedTextAttributes() != null) {
needEmptyAction = false;
}
if (needEmptyAction && emptyActionRegistered.add(Pair.create(highlightInfo.getFixTextRange(), tool.getShortName()))) {
IntentionAction emptyIntentionAction = new EmptyIntentionAction(tool.getDisplayName());
QuickFixAction.registerQuickFixAction(highlightInfo, emptyIntentionAction, key);
}
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class GutterIntentionAction method addActions.
private static void addActions(@NotNull Project project, @NotNull RangeHighlighterEx info, @NotNull List<HighlightInfo.IntentionActionDescriptor> descriptors, @NotNull AnActionEvent event) {
final GutterIconRenderer r = info.getGutterIconRenderer();
if (r == null || DumbService.isDumb(project) && !DumbService.isDumbAware(r)) {
return;
}
List<HighlightInfo.IntentionActionDescriptor> list = new ArrayList<>();
for (AnAction action : ar(r.getClickAction(), r.getMiddleButtonClickAction(), r.getRightButtonClickAction(), r.getPopupMenuActions())) {
if (action != null) {
addActions(action, list, r, 0, event);
}
}
if (list.isEmpty())
return;
if (list.size() == 1) {
descriptors.addAll(list);
} else {
HighlightInfo.IntentionActionDescriptor first = list.get(0);
List<IntentionAction> options = ContainerUtil.map(list.subList(1, list.size()), HighlightInfo.IntentionActionDescriptor::getAction);
descriptors.add(new HighlightInfo.IntentionActionDescriptor(first.getAction(), options, null, first.getIcon()));
}
}
Aggregations