InnerClassUsages (@NotNull PsiLocalVariable local, @NotNull List<PsiReferenceExpression> allRefs) { final List<PsiElement> innerClassesWithUsages = new ArrayList<>(); final List<PsiElement> innerClassUsages = new ArrayList<>(); final PsiElement containingClass = LambdaUtil.getContainingClassOrLambda(local); for (PsiElement element : allRefs) { PsiElement innerClass = element; while (innerClass != null) { final PsiElement parentPsiClass = LambdaUtil.getContainingClassOrLambda(innerClass.getParent()); if (parentPsiClass == containingClass) { if (innerClass != element) { innerClassesWithUsages.add(innerClass); innerClassUsages.add(element); } break; } innerClass = parentPsiClass; } } return new InnerClassUsages(innerClassesWithUsages, innerClassUsages); }