public void testTypingDoesNotInterfereWithDuplicates() throws Exception { SliceTreeStructure treeStructure = configureTree("DupSlice"); SliceNode root = (SliceNode) treeStructure.getRootElement(); List<SliceNode> nodes = new ArrayList<SliceNode>(); expandNodesTo(root, nodes); for (int i = 0; i < nodes.size() - 1; i++) { SliceNode node = nodes.get(i); assertNull(node.getDuplicate()); } SliceNode last = nodes.get(nodes.size() - 1); assertNotNull(last.getDuplicate()); type(" xx"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); backspace(); backspace(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); nodes.clear(); expandNodesTo(root, nodes); for (int i = 0; i < nodes.size() - 1; i++) { SliceNode node = nodes.get(i); assertNull(node.getDuplicate()); } assertNotNull(last.getDuplicate()); }
private SliceTreeStructure configureTree(@NonNls final String name) throws Exception { configureByFile("/codeInsight/slice/backward/" + name + ".java"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiElement element = new SliceHandler(true).getExpressionAtCaret(getEditor(), getFile()); assertNotNull(element); Collection<HighlightInfo> errors = highlightErrors(); assertEmpty(errors); SliceAnalysisParams params = new SliceAnalysisParams(); params.scope = new AnalysisScope(getProject()); params.dataFlowToThis = true; SliceUsage usage = SliceUsage.createRootUsage(element, params); SlicePanel panel = new SlicePanel( getProject(), true, new SliceRootNode(getProject(), new DuplicateMap(), usage), false, ToolWindowHeadlessManagerImpl.HEADLESS_WINDOW) { @Override protected void close() {} @Override public boolean isAutoScroll() { return false; } @Override public void setAutoScroll(boolean autoScroll) {} @Override public boolean isPreview() { return false; } @Override public void setPreview(boolean preview) {} }; Disposer.register(getProject(), panel); return (SliceTreeStructure) panel.getBuilder().getTreeStructure(); }