void () { @Language("JAVA") String text = "public class X{ int xxx; } //comment"; PsiFile psiFile = myFixture.addFileToProject("X.java", text); Usage usage = new UsageInfo2UsageAdapter( new UsageInfo(psiFile, psiFile.getText().indexOf("xxx"), StringUtil.indexOfSubstringEnd(psiFile.getText(), "xxx"))); UsageViewImpl usageView = createUsageView(usage); Node[] usageNode = new Node[1]; TreeUtil.traverse(usageView.getRoot(), node -> { if (node instanceof UsageNode && ((UsageNode)node).getUsage() == usage) { usageNode[0] = (UsageNode)node; } return true; }); Node nodeToExclude = (Node)usageNode[0].getParent(); JComponent component = usageView.getComponent(); DataProvider provider = DataManagerImpl.getDataProviderEx(component); ExclusionHandler exclusionHandler = (ExclusionHandler)provider.getData(ExclusionHandler.EXCLUSION_HANDLER.getName()); exclusionHandler.excludeNode(nodeToExclude); UIUtil.dispatchAllInvocationEvents(); Set<Node> excluded = new HashSet<>(); TreeUtil.traverse(usageView.getRoot(), node -> { if (((Node)node).isExcluded()) { excluded.add((Node)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); exclusionHandler.includeNode(nodeToExclude); UIUtil.dispatchAllInvocationEvents(); excluded.clear(); TreeUtil.traverse(usageView.getRoot(), node -> { if (((Node)node).isExcluded()) { excluded.add((Node)node); } return true; }); assertEmpty(excluded); }