mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDE
Handle a situation when the root is not shown
This commit is contained in:
+39
-2
@@ -21,6 +21,7 @@ import gnu.trove.TObjectProcedure;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.ArrangementUtil.and;
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.FIELD;
|
||||
@@ -135,7 +136,7 @@ public class ArrangementRuleEditingModelImplTest extends AbstractArrangementRule
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeLastRowConditionFromMultiChildrenParent() {
|
||||
public void removeFirstRowConditionFromMultiChildrenParent() {
|
||||
configure(and(atom(FIELD), atom(PUBLIC)));
|
||||
configure(and(atom(FIELD), atom(STATIC)));
|
||||
|
||||
@@ -159,7 +160,7 @@ public class ArrangementRuleEditingModelImplTest extends AbstractArrangementRule
|
||||
assertNotNull(atomFieldNode);
|
||||
assertEquals(atom(FIELD), atomFieldNode.getUserObject());
|
||||
|
||||
DefaultMutableTreeNode layeredFieldNode = atomFieldNode.getNextNode();
|
||||
DefaultMutableTreeNode layeredFieldNode = atomFieldNode.getNextSibling();
|
||||
assertNotNull(atomFieldNode);
|
||||
assertEquals(atom(FIELD), atomFieldNode.getUserObject());
|
||||
|
||||
@@ -169,6 +170,42 @@ public class ArrangementRuleEditingModelImplTest extends AbstractArrangementRule
|
||||
|
||||
checkTreeNodesConsistency();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeLastRowConditionFromMultiChildrenParent() {
|
||||
configure(and(atom(FIELD), atom(PUBLIC)));
|
||||
configure(and(atom(FIELD), atom(STATIC)));
|
||||
|
||||
ArrangementRuleEditingModel siblingModel = myRowMappings.get(2);
|
||||
assertNotNull(siblingModel);
|
||||
|
||||
ArrangementRuleEditingModel modelToChange = myRowMappings.get(3);
|
||||
assertNotNull(modelToChange);
|
||||
assertEquals(2, myRowMappings.size());
|
||||
|
||||
modelToChange.removeAndCondition(atom(STATIC));
|
||||
|
||||
assertEquals(2, myRowMappings.size());
|
||||
assertSame(siblingModel, myRowMappings.get(2));
|
||||
assertEquals(and(atom(FIELD), atom(PUBLIC)), siblingModel.getSettingsNode());
|
||||
|
||||
assertSame(modelToChange, myRowMappings.get(3));
|
||||
assertEquals(atom(FIELD), modelToChange.getSettingsNode());
|
||||
|
||||
DefaultMutableTreeNode compositeFieldNode = (DefaultMutableTreeNode)myRoot.getFirstChild();
|
||||
assertNotNull(compositeFieldNode);
|
||||
assertEquals(atom(FIELD), compositeFieldNode.getUserObject());
|
||||
|
||||
DefaultMutableTreeNode publicNode = (DefaultMutableTreeNode)compositeFieldNode.getFirstChild();
|
||||
assertNotNull(publicNode);
|
||||
assertEquals(atom(PUBLIC), publicNode.getUserObject());
|
||||
|
||||
DefaultMutableTreeNode atomFieldNode = compositeFieldNode.getNextSibling();
|
||||
assertNotNull(atomFieldNode);
|
||||
assertEquals(atom(FIELD), atomFieldNode.getUserObject());
|
||||
|
||||
checkTreeNodesConsistency();
|
||||
}
|
||||
|
||||
private void checkTreeNodesConsistency() {
|
||||
final Ref<DefaultMutableTreeNode> rootRef = new Ref<DefaultMutableTreeNode>();
|
||||
|
||||
Reference in New Issue
Block a user