void (@NotNull PsiReferenceExpression expression) { if (escaping) { return; } super.visitReferenceExpression(expression); final PsiElement target = expression.resolve(); if (!myVariable.equals(target)) { return; } final PsiElement context = PsiTreeUtil.getParentOfType(expression, PsiMember.class, PsiLambdaExpression.class); if (context != null && PsiTreeUtil.isAncestor(myContext, context, true)) { // strictly speaking a value can also escape via method call or return statement, but // since it is difficult to guarantee synchronization and thus correctness on accessing such values, // we want to warn on those cases and don't detect them here. escaping = true; } }