void () { PsiClass xv = myJavaFacade.findClass("XValueContainerNode", GlobalSearchScope.allScope(myProject)); PsiMethod method = xv.findMethodsByName("setObsolete", false)[0]; FindUsagesHandler handler = ((FindManagerImpl)FindManager.getInstance(getProject())).getFindUsagesManager() .getFindUsagesHandler(method, FindUsagesHandlerFactory.OperationMode.USAGES_WITH_DEFAULT_OPTIONS); PsiElement[] elements = handler.getPrimaryElements(); int[] count = {0}; for (PsiElement element : elements) { handler.processElementUsages(element, info -> { count[0]++; PsiClass containing = PsiTreeUtil.getParentOfType(info.getElement(), PsiClass.class); assertEquals("Use", containing.getName()); return true; }, handler.getFindUsagesOptions()); } assertEquals(1, count[0]); }