void () { @Language("JAVA") String fileText = "public class X{ int xxx; } //comment"; PsiFile psiFile = myFixture.addFileToProject("X.java", fileText); Usage usage = new UsageInfo2UsageAdapter( new UsageInfo(psiFile, psiFile.getText().indexOf("xxx"), StringUtil.indexOfSubstringEnd(psiFile.getText(), "xxx"))); UsageViewImpl usageView = createUsageView(usage); usageView.excludeUsages(new Usage[]{usage}); UIUtil.dispatchAllInvocationEvents(); Set<Node> excluded = new HashSet<>(); Node[] usageNode = new Node[1]; TreeUtil.traverse(usageView.getRoot(), node -> { if (((Node)node).isExcluded()) { excluded.add((Node)node); } if (node instanceof UsageNode && ((UsageNode)node).getUsage() == usage) { usageNode[0] = (UsageNode)node; } return true; }); Set<Node> expectedExcluded = new HashSet<>(); for (TreeNode n = usageNode[0]; n != usageView.getRoot(); n = n.getParent()) { expectedExcluded.add((Node)n); } assertEquals(expectedExcluded, excluded); usageView.includeUsages(new Usage[]{usage}); UIUtil.dispatchAllInvocationEvents(); excluded.clear(); TreeUtil.traverse(usageView.getRoot(), node -> { if (((Node)node).isExcluded()) { excluded.add((Node)node); } return true; }); assertEmpty(excluded); String text = new ExporterToTextFile(usageView, UsageViewSettings.getInstance()).getReportText(); assertEquals(""" Usages in (1 usage found) Unclassified (1 usage found) light_idea_test_case (1 usage found) (1 usage found) X.java (1 usage found) 1 public class X{ int xxx; } //comment """, StringUtil.convertLineSeparators(text)); }