static boolean hasVarReference(PsiElement expressionOrCodeBlock, String name, ChainContext context) {
    PsiLambdaExpression lambda = (PsiLambdaExpression)context.createExpression(name + "->" + expressionOrCodeBlock.getText());
    PsiParameter var = lambda.getParameterList().getParameters()[0];
    PsiElement body = lambda.getBody();
    LOG.assertTrue(body != null);
    return ReferencesSearch.search(var, new LocalSearchScope(body)).findFirst() != null;
  }
static boolean hasVarReference(PsiElement expressionOrCodeBlock, String name, ChainContext context)