mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDE
Correct tree merge when non-first rule should be merged down
This commit is contained in:
+34
@@ -139,6 +139,40 @@ node = '4'()
|
||||
checkRowMappings([:], rowMappings)
|
||||
}
|
||||
|
||||
@Test
|
||||
void replaceWithTwoLevelMergeToNodeBelow() {
|
||||
// Init.
|
||||
def from;
|
||||
def to;
|
||||
def initial = new TreeNodeBuilder().
|
||||
'0' {
|
||||
from = '1'() {
|
||||
'2'()
|
||||
to = '3'()}
|
||||
'4'() {
|
||||
'5'() }
|
||||
}
|
||||
|
||||
// Modify.
|
||||
def replacement = new TreeNodeBuilder().
|
||||
'4' {
|
||||
'3'()
|
||||
}
|
||||
def rowMappings = doReplace(initial, from, to, replacement)
|
||||
|
||||
// Check.
|
||||
def expected = new TreeNodeBuilder().
|
||||
'0' {
|
||||
'1' {
|
||||
'2'()}
|
||||
'4' {
|
||||
'3'()
|
||||
'5'()}
|
||||
}
|
||||
assertNodesEqual(expected, initial)
|
||||
checkRowMappings([:], rowMappings)
|
||||
}
|
||||
|
||||
@Test
|
||||
void addWithoutMergeAbove() {
|
||||
def initial = new TreeNodeBuilder().
|
||||
|
||||
+12
-1
@@ -341,7 +341,18 @@ public class ArrangementConfigUtil {
|
||||
int insertionIndex = root.getChildCount() < childCountBefore ? childCountBefore - 1 : childCountBefore;
|
||||
boolean merged = insert(root, insertionIndex, replacement, treeModel);
|
||||
if (cutHierarchy != null) {
|
||||
insert(root, insertionIndex + (merged ? 0 : 1), cutHierarchy, treeModel);
|
||||
List<ArrangementTreeNode> toInsert = new ArrayList<ArrangementTreeNode>();
|
||||
if (hasEqualSetting(root, cutHierarchy)) {
|
||||
for (int i = 0; i < cutHierarchy.getChildCount(); i++) {
|
||||
toInsert.add(cutHierarchy.getChildAt(i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
toInsert.add(cutHierarchy);
|
||||
}
|
||||
for (ArrangementTreeNode node : toInsert) {
|
||||
insert(root, root.getChildCount(), node, treeModel);
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user