diff --git a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java index c413ebd4b..9f174406d 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java @@ -3614,6 +3614,31 @@ public boolean containsOnlyBlockMappings() { return count > 0 && count == getMappings().size(); } + public boolean containsOnlySystemCalls() { + int count = 0; + for(AbstractCodeMapping mapping : getMappings()) { + if(mapping.getFragment1().getString().startsWith("System.") && mapping.getFragment2().getString().startsWith("System.") && + !mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) { + count++; + } + else if(mapping.getFragment1().getString().startsWith(JAVA.THROW_SPACE + "new") && mapping.getFragment2().getString().startsWith(JAVA.THROW_SPACE + "new") && + !mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) { + count++; + } + else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK)) { + count++; + } + else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.FINALLY_BLOCK) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.FINALLY_BLOCK)) { + count++; + } + else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT) && + !mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) { + count++; + } + } + return count > 0 && count == getMappings().size(); + } + public int mappingsWithoutBlocks() { int count = 0; Set subExpressionMappings = new LinkedHashSet<>(); diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java index a725e624c..b16c33fc2 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java @@ -4623,6 +4623,9 @@ private boolean anotherAddedMethodExistsWithBetterMatchingInvocationExpression(A private boolean extractAndMoveMatchCondition(UMLOperationBodyMapper operationBodyMapper, UMLOperationBodyMapper parentMapper, AbstractCall addedOperationInvocation) { List mappingList = new ArrayList(operationBodyMapper.getMappings()); + if(operationBodyMapper.containsOnlySystemCalls()) { + return false; + } if(operationBodyMapper.getContainer2().isGetter() && mappingList.size() == 1) { List parentMappingList = new ArrayList(parentMapper.getMappings()); for(AbstractCodeMapping mapping : parentMappingList) { diff --git a/src/test/java/org/refactoringminer/test/TestAllRefactorings.java b/src/test/java/org/refactoringminer/test/TestAllRefactorings.java index 0e9ed7566..53f05e265 100644 --- a/src/test/java/org/refactoringminer/test/TestAllRefactorings.java +++ b/src/test/java/org/refactoringminer/test/TestAllRefactorings.java @@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception { GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl(); TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue()); RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test); - test.assertExpectationsWithGitHubAPI(12404, 22, 226); + test.assertExpectationsWithGitHubAPI(12404, 21, 226); } }