void () { PsiClass aClass = myFixture.addClass("class Foo {public void bar(int i){}}"); Project project = myFixture.getProject(); GlobalInspectionContext context = InspectionManager.getInstance(project).createNewGlobalContext(); ((GlobalInspectionContextBase)context).initializeTools(new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); RefManagerImpl refManager = new RefManagerImpl(project, new AnalysisScope(aClass.getContainingFile()), context); refManager.findAllDeclarations(); List<RefElement> sortedElements = refManager.getSortedElements(); RefElement refMethod = refManager.getReference(aClass.getMethods()[0]); List<RefEntity> children = refMethod.getChildren(); ArrayList<RefElement> deletedRefs = new ArrayList<>(); refManager.removeRefElement(refMethod, deletedRefs); assertTrue(deletedRefs.containsAll(children)); assertTrue(deletedRefs.contains(refMethod)); //check that table was not reinitialized due to full table traversal assertSame(sortedElements, refManager.getSortedElements()); }