String[] (final String value) { final StringBuffer usedMnemonics = new StringBuffer(); RadContainer container = myComponent.getParent(); if (container != null) { while (container.getParent() != null) { container = container.getParent(); } FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() { @Override public boolean visit(final IComponent component) { SupportCode.TextWithMnemonic twm = DuplicateMnemonicInspection.getTextWithMnemonic(myEditor.getModule(), component); if (twm != null) { usedMnemonics.append(twm.getMnemonicChar()); } return true; } }); } ArrayList<String> variants = new ArrayList<>(); // try upper-case and word start characters for(int i=0; i<value.length(); i++) { final char ch = value.charAt(i); if (i == 0 || Character.isUpperCase(ch) || value.charAt(i - 1) == ' ') { if (Character.isLetter(ch) && usedMnemonics.indexOf(StringUtil.toUpperCase(String.valueOf(ch))) < 0) { variants.add(value.substring(0, i) + "&" + value.substring(i)); } } } if (variants.size() == 0) { // try any unused characters for(int i=0; i<value.length(); i++) { final char ch = value.charAt(i); if (Character.isLetter(ch) && usedMnemonics.indexOf(StringUtil.toUpperCase(String.valueOf(ch))) < 0) { variants.add(value.substring(0, i) + "&" + value.substring(i)); } } } if (variants.size() == 0) { variants.add(value); } return ArrayUtilRt.toStringArray(variants); }