RegExp: do not allow adding inspection with an existing name

GitOrigin-RevId: 63bf6ccc189cac5bd81c7b4f9eb7876f932b37de
This commit is contained in:
Bas Leijdekkers
2023-01-23 16:53:30 +01:00
committed by intellij-monorepo-bot
parent a344209553
commit 6eb6d14019
2 changed files with 14 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ color.settings.quantifier=Quantifier
color.settings.quote.character=Quote escape
color.settings.redundant.escape.sequence=Redundant escape sequence
color.settings.title.regexp=RegExp
dialog.message.inspection.with.name.exists.warning=Inspection with name ''{0}'' already exists
dialog.message.name.must.not.be.empty=Name must not be empty
dialog.message.suppress.id.already.in.use.by.another.inspection=Suppress ID ''{0}'' is already in use by another inspection
dialog.message.suppress.id.must.match.regex.za.z=Suppress ID must match regex [a-zA-Z_0-9.-]+

View File

@@ -67,6 +67,19 @@ public class MetaDataDialog extends DialogWrapper {
if (StringUtil.isEmpty(name)) {
warnings.add(new ValidationInfo(RegExpBundle.message("dialog.message.name.must.not.be.empty"), myNameTextField));
}
else {
for (RegExpInspectionConfiguration configuration : configurations) {
if (myNewInspection) {
if (configuration.getName().equals(name)) {
warnings.add(new ValidationInfo(RegExpBundle.message("dialog.message.inspection.with.name.exists.warning", name), myNameTextField));
break;
}
} else if (!configuration.getUuid().equals(myConfiguration.getUuid()) && configuration.getName().equals(name)) {
warnings.add(new ValidationInfo(RegExpBundle.message("dialog.message.inspection.with.name.exists.warning", name), myNameTextField));
break;
}
}
}
final String suppressId = getSuppressId();
if (!StringUtil.isEmpty(suppressId)) {
if (!mySuppressIdPattern.matcher(suppressId).matches()) {