String[] (final ExpressionContext context) { String[] names = ExpressionUtil.getNames(context); if (names == null || names.length == 0) return names; PsiFile file = PsiDocumentManager.getInstance(context.getProject()).getPsiFile(context.getEditor().getDocument()); PsiElement e = file.findElementAt(context.getStartOffset()); PsiVariable[] vars = MacroUtil.getVariablesVisibleAt(e, ""); LinkedList<String> namesList = new LinkedList<>(Arrays.asList(names)); for (PsiVariable var : vars) { if (e.equals(var.getNameIdentifier())) continue; namesList.remove(var.getName()); } if (namesList.isEmpty()) { String name = names[0]; index: for (int j = 1; ; j++) { String name1 = name + j; for (PsiVariable var : vars) { if (name1.equals(var.getName()) && !var.getNameIdentifier().equals(e)) continue index; } return new String[]{name1}; } } return ArrayUtilRt.toStringArray(namesList); }