diff --git a/RegExpSupport/resources/META-INF/RegExpPlugin.xml b/RegExpSupport/resources/META-INF/RegExpPlugin.xml index 2e706f676e6b..680305dcd5dc 100644 --- a/RegExpSupport/resources/META-INF/RegExpPlugin.xml +++ b/RegExpSupport/resources/META-INF/RegExpPlugin.xml @@ -30,6 +30,7 @@ + org.intellij.lang.regexp.intention.CheckRegExpIntentionAction diff --git a/RegExpSupport/resources/messages/RegExpBundle.properties b/RegExpSupport/resources/messages/RegExpBundle.properties index c082c68bb47b..09039ce47c7c 100644 --- a/RegExpSupport/resources/messages/RegExpBundle.properties +++ b/RegExpSupport/resources/messages/RegExpBundle.properties @@ -123,6 +123,9 @@ inspection.warning.redundant.class.element=Redundant ''{0}'' in RegExp inspection.warning.redundant.nested.character.class=Redundant nested character class inspection.warning.single.character.alternation.in.regexp=Single character alternation in RegExp inspection.warning.unnecessary.non.capturing.group=Unnecessary non-capturing group {0} +inspection.tree.create.inspection=Using a RegExp\u2026 +inspection.tree.group.description=Use the + button in the toolbar to create a new RegExp inspection.
\ +RegExp inspections highlight code snippets matching the specified regular expression. A quick-fix can be provided by adding a second regular expression. intention.family.name.replace=Replace intention.name.check.regexp=Check RegExp label.any=Any diff --git a/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/CustomRegExpFakeInspection.java b/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/CustomRegExpFakeInspection.java index 4f4755b50743..474066432583 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/CustomRegExpFakeInspection.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/CustomRegExpFakeInspection.java @@ -47,6 +47,7 @@ import java.util.List; */ public class CustomRegExpFakeInspection extends LocalInspectionTool { + private static final String GROUP = "RegExp"; @NotNull private final RegExpInspectionConfiguration myConfiguration; public CustomRegExpFakeInspection(@NotNull RegExpInspectionConfiguration configuration) { @@ -107,15 +108,19 @@ public class CustomRegExpFakeInspection extends LocalInspectionTool { return CustomRegExpInspection.SHORT_NAME; } + public static String[] getGroup() { + return new String[] {InspectionsBundle.message("group.names.user.defined"), GROUP}; + } + @Nls(capitalization = Nls.Capitalization.Sentence) @Override public @NotNull String getGroupDisplayName() { - return "RegExp"; + return GROUP; } @Override public @Nls(capitalization = Nls.Capitalization.Sentence) String @NotNull [] getGroupPath() { - return new String[] {InspectionsBundle.message("group.names.user.defined"), getGroupDisplayName()}; + return getGroup(); } @Nullable diff --git a/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/RegExpAdvertiser.java b/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/RegExpAdvertiser.java new file mode 100644 index 000000000000..b5de0a0cf26d --- /dev/null +++ b/RegExpSupport/src/org/intellij/lang/regexp/inspection/custom/RegExpAdvertiser.java @@ -0,0 +1,26 @@ +package org.intellij.lang.regexp.inspection.custom; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.profile.codeInspection.ui.InspectionTreeAdvertiser; +import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; +import org.intellij.lang.regexp.RegExpBundle; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class RegExpAdvertiser extends InspectionTreeAdvertiser { + + @Override + public @NotNull List getActions(SingleInspectionProfilePanel panel) { + return List.of( + new RegExpProfileActionProvider.AddCustomRegExpInspectionAction(panel, RegExpBundle.message("inspection.tree.create.inspection"), false) + ); + } + + @Override + public List getCustomGroups() { + return List.of( + new CustomGroup(CustomRegExpFakeInspection.getGroup(), RegExpBundle.message("inspection.tree.group.description")) + ); + } +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionTreeAdvertiser.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionTreeAdvertiser.java index 8abdfe193b6f..4641018f67d2 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionTreeAdvertiser.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionTreeAdvertiser.java @@ -5,7 +5,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.extensions.ExtensionPointName; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.List; /** @@ -20,7 +19,7 @@ public abstract class InspectionTreeAdvertiser { * They appear when no inspections are found after filtering the inspection tree. */ @NotNull - public abstract List getActions(SingleInspectionProfilePanel panel); + public List getActions(SingleInspectionProfilePanel panel) { return List.of(); } public record CustomGroup(String[] path, String description) {} @@ -29,5 +28,5 @@ public abstract class InspectionTreeAdvertiser { *
  • will always be displayed
  • *
  • can have a custom description
  • */ - public List getCustomGroups() { return new ArrayList<>(); } + public List getCustomGroups() { return List.of(); } }