[xena] IDEA-60082 Invalid nodes appear in Project Tree after Undo Move a class from a file if the class has usages in the current file

This commit is contained in:
Kirill Kalishev
2011-05-20 15:10:51 +04:00
parent 8b4ec046e0
commit 6ec3d4b8bf
2 changed files with 62 additions and 11 deletions
@@ -1136,6 +1136,9 @@ public class AbstractTreeUi {
}
else {
notRequiredToUpdateChildren = alwaysPlus;
if (notRequiredToUpdateChildren && !wasExpanded && !myUnbuiltNodes.contains(node)) {
removeChildren(node);
}
}
}
@@ -4622,14 +4625,15 @@ public class AbstractTreeUi {
}
}
private void removeChildren(DefaultMutableTreeNode node) {
EnumerationCopy copy = new EnumerationCopy(node.children());
while (copy.hasMoreElements()) {
disposeNode((DefaultMutableTreeNode)copy.nextElement());
}
node.removeAllChildren();
myTreeModel.nodeStructureChanged(node);
}
private void removeChildren(DefaultMutableTreeNode node) {
EnumerationCopy copy = new EnumerationCopy(node.children());
while (copy.hasMoreElements()) {
disposeNode((DefaultMutableTreeNode)copy.nextElement());
}
node.removeAllChildren();
myTreeModel.nodeStructureChanged(node);
}
private void maybeUpdateSubtreeToUpdate(final DefaultMutableTreeNode subtreeRoot) {
@@ -5,6 +5,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Progressive;
import com.intellij.openapi.util.*;
import com.intellij.ui.LoadingNode;
import com.intellij.util.Time;
import com.intellij.util.WaitFor;
import com.intellij.util.ui.UIUtil;
@@ -2258,6 +2259,56 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
assertTree("-/\n" + " +com\n" + " -[jetbrains]\n" + " -fabrique\n" + " ide\n" + " +org\n" + " +xunit\n");
}
public void testUpdateCollapsedBuiltNode() throws Exception {
buildStructure(myRoot, false);
myCom.removeAll();
myAlwaysShowPlus.add(new NodeElement("com"));
activate();
buildNode("/", false);
assertTree("-/\n" +
" +com\n" +
" +jetbrains\n" +
" +org\n" +
" +xunit\n");
final DefaultMutableTreeNode com = findNode("com", false);
assertEquals(1, com.getChildCount());
assertEquals(LoadingNode.getText(), com.getChildAt(0).toString());
expand(getPath("com"));
assertTree("-/\n" +
" com\n" +
" +jetbrains\n" +
" +org\n" +
" +xunit\n");
myCom.addChild(myIntellij);
updateFrom(new NodeElement("com"));
assertTree("-/\n" +
" +com\n" +
" +jetbrains\n" +
" +org\n" +
" +xunit\n");
assertEquals(1, com.getChildCount());
assertEquals("intellij", com.getChildAt(0).toString());
myCom.removeAll();
updateFrom(new NodeElement("com"));
expand(getPath("com"));
assertTree("-/\n" +
" com\n" +
" +jetbrains\n" +
" +org\n" +
" +xunit\n");
}
public void testReleaseBuilderDuringGetChildren() throws Exception {
assertReleaseDuringBuilding("getChildren", "fabrique", new Runnable() {
@Override
@@ -2369,10 +2420,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
super(true, false);
}
@Override
public void testBatchUpdate() throws Exception {
super.testBatchUpdate();
}
}
public static class BgLoadingSyncUpdate extends TreeUiTest {