String (@NotNull ArrangementSectionRuleManager.ArrangementSectionRuleData data, int index) { int startSectionIndex = -1; final Set<String> sectionRules = new HashSet<>(); for (int i = 0; i < index; i++) { final ArrangementSectionRuleManager.ArrangementSectionRuleData section = extractSectionText(i); if (section != null) { startSectionIndex = section.isSectionStart() ? i : -1; if (StringUtil.isNotEmpty(section.getText())) { sectionRules.add(section.getText()); } } } if (StringUtil.isNotEmpty(data.getText()) && sectionRules.contains(data.getText())) { return ApplicationBundle.message("arrangement.settings.validation.duplicate.section.text"); } if (!data.isSectionStart()) { if (startSectionIndex == -1) { return ApplicationBundle.message("arrangement.settings.validation.end.section.rule.without.start"); } else if (startSectionIndex == index - 1) { return ApplicationBundle.message("arrangement.settings.validation.empty.section.rule"); } } return null; }