diff --git a/src/main/java/gr/uom/java/xmi/decomposition/LeafMapping.java b/src/main/java/gr/uom/java/xmi/decomposition/LeafMapping.java index 81cf7f5ea8..377d54dd27 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/LeafMapping.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/LeafMapping.java @@ -338,6 +338,22 @@ else if(!nestedUnderCatchBlockOfSameType1 && nestedUnderCatchBlockOfSameType2) { else if(streamAPIMigration2 && !streamAPIMigration1) { return 1; } + if(this.getFragment1().getVariableDeclarations().size() > 0 && this.getFragment2().getVariableDeclarations().size() > 0 && + o.getFragment1().getVariableDeclarations().size() > 0 && o.getFragment2().getVariableDeclarations().size() > 0 && + Math.abs(distance1 - distance2) < 0.02) { + int depthDiff1 = Math.abs(this.getFragment1().getDepth() - this.getFragment2().getDepth()); + int depthDiff2 = Math.abs(o.getFragment1().getDepth() - o.getFragment2().getDepth()); + if(depthDiff1 != depthDiff2) { + return Integer.valueOf(depthDiff1).compareTo(Integer.valueOf(depthDiff2)); + } + else { + int indexDiff1 = Math.abs(this.getFragment1().getIndex() - this.getFragment2().getIndex()); + int indexDiff2 = Math.abs(o.getFragment1().getIndex() - o.getFragment2().getIndex()); + if(indexDiff1 != indexDiff2) { + return Integer.valueOf(indexDiff1).compareTo(Integer.valueOf(indexDiff2)); + } + } + } return Double.compare(distance1, distance2); } else {