[codeInspection.ui] Register InspectionProfileActionProvider#getAddActions in the inspection profile panel

IJ-CR-117041

GitOrigin-RevId: 7075cd66dd8019673dff9542b7c717a5b2b1a4a5
This commit is contained in:
Louis Vignier
2023-10-27 18:34:25 +02:00
committed by intellij-monorepo-bot
parent af6f095623
commit c38cdeb515
7 changed files with 40 additions and 21 deletions

View File

@@ -125,7 +125,8 @@ inspection.warning.single.character.alternation.in.regexp=Single character alter
inspection.warning.unnecessary.non.capturing.group=Unnecessary non-capturing group <code>{0}</code>
inspection.tree.create.inspection=Using a RegExp\u2026
inspection.tree.group.description=Use the + button in the toolbar to create a new RegExp inspection.<br>\
RegExp inspections highlight code snippets matching the specified regular expression. A quick-fix can be provided by adding a second regular expression.
RegExp inspections highlight code snippets matching the specified regular expression. A quick-fix can be provided by adding a string template which may contain group references (e.g. <code>$1</code>).<br><br>\
<a href="action://regexp.profile.action.provider.add.group">Add Custom RegExp Inspection\u2026</a>
intention.family.name.replace=Replace
intention.name.check.regexp=Check RegExp
label.any=Any

View File

@@ -3,27 +3,29 @@ package org.intellij.lang.regexp.inspection.custom;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ex.InspectionProfileModifiableModel;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsActions;
import com.intellij.openapi.util.Pair;
import com.intellij.profile.codeInspection.ui.InspectionMetaDataDialog;
import com.intellij.profile.codeInspection.ui.InspectionProfileActionProvider;
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
import org.intellij.lang.regexp.RegExpBundle;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import org.jetbrains.annotations.Nullable;
public class RegExpProfileActionProvider extends InspectionProfileActionProvider {
@Override
public @NotNull List<AnAction> getAddActions(@NotNull SingleInspectionProfilePanel panel) {
return List.of(
public @Nullable Pair<@NotNull ActionGroup, @NotNull String> getAddActions(@NotNull SingleInspectionProfilePanel panel) {
final var group = new DefaultActionGroup(
new AddCustomRegExpInspectionAction(panel, RegExpBundle.message("action.add.regexp.search.inspection.text"), false),
new AddCustomRegExpInspectionAction(panel, RegExpBundle.message("action.add.regexp.replace.inspection.text"), true)
);
return Pair.create(group, "regexp.profile.action.provider.add.group");
}
static final class AddCustomRegExpInspectionAction extends DumbAwareAction {