UniqueNameGenerator (PsiElement scopeElement) { UniqueNameGenerator uniqueNameGenerator = new UniqueNameGenerator(); for (VariableData data : myInputVariables.getInputVariables()) { if (data.variable != null) { String name = data.variable.getName(); if (name != null) uniqueNameGenerator.addExistingName(name); } } for (PsiVariable variable : myOutputVariables) { String name = variable.getName(); if (name != null) uniqueNameGenerator.addExistingName(name); } PsiElement superParent = PsiTreeUtil.getParentOfType(scopeElement, PsiMember.class, PsiLambdaExpression.class); if (superParent != null) { SyntaxTraverser.psiTraverser().withRoot(superParent) .filter(element -> element instanceof PsiVariable) .forEach(element -> { String name = ((PsiVariable)element).getName(); if (name != null) uniqueNameGenerator.addExistingName(name); }); } return uniqueNameGenerator; }