String (@NotNull PsiLambdaExpression lambdaExpression) { final PsiClass upper = PsiTreeUtil.getParentOfType(lambdaExpression, PsiClass.class); if (upper == null) { return null; } ParameterizedCachedValue<Map<PsiLambdaExpression, String>, PsiClass> value = upper.getUserData(LAMBDA_NAME); if (value == null) { value = CachedValuesManager.getManager(upper.getProject()).createParameterizedCachedValue( new ParameterizedCachedValueProvider<Map<PsiLambdaExpression, String>, PsiClass>() { @Override public CachedValueProvider.Result<Map<PsiLambdaExpression, String>> compute(final PsiClass upper) { final Map<PsiLambdaExpression, String> map = new HashMap<>(); upper.accept(new JavaRecursiveElementWalkingVisitor() { int index; @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) { map.put(expression, "$" + index++); super.visitLambdaExpression(expression); } @Override public void visitClass(@NotNull PsiClass aClass) { if (aClass == upper) { super.visitClass(aClass); } } }); return CachedValueProvider.Result.create(map, upper); } }, false); upper.putUserData(LAMBDA_NAME, value); } return "lambda" + getLambdaPrefix(lambdaExpression) + value.getValue(upper).get(lambdaExpression); }