private void checkForExtractedOperations() { List<UMLOperation> operationsToBeRemoved = new ArrayList<UMLOperation>(); for(Iterator<UMLOperation> addedOperationIterator = addedOperations.iterator(); addedOperationIterator.hasNext();) { UMLOperation addedOperation = addedOperationIterator.next(); for(UMLOperationBodyMapper mapper : getOperationBodyMapperList()) { ExtractOperationDetection detection = new ExtractOperationDetection(addedOperations, modelDiff); ExtractOperationRefactoring refactoring = detection.check(mapper, addedOperation); if(refactoring != null) { refactorings.add(refactoring); UMLOperationBodyMapper operationBodyMapper = refactoring.getBodyMapper(); refactorings.addAll(operationBodyMapper.getRefactorings()); mapper.addAdditionalMapper(operationBodyMapper); operationsToBeRemoved.add(addedOperation); } } } addedOperations.removeAll(operationsToBeRemoved); }
private void checkForExtractedOperationsWithinMovedMethod(UMLOperationBodyMapper movedMethodMapper, UMLClass addedClass) { UMLOperation removedOperation = movedMethodMapper.getOperation1(); UMLOperation addedOperation = movedMethodMapper.getOperation2(); Set<OperationInvocation> removedInvocations = removedOperation.getAllOperationInvocations(); Set<OperationInvocation> addedInvocations = addedOperation.getAllOperationInvocations(); Set<OperationInvocation> intersection = new LinkedHashSet<OperationInvocation>(removedInvocations); intersection.retainAll(addedInvocations); Set<OperationInvocation> newInvocations = new LinkedHashSet<OperationInvocation>(addedInvocations); newInvocations.removeAll(intersection); for(OperationInvocation newInvocation : newInvocations) { for(UMLOperation operation : addedClass.getOperations()) { if(!operation.isAbstract() && !operation.hasEmptyBody() && newInvocation.matchesOperation(operation, addedOperation.variableTypeMap(), this)) { ExtractOperationDetection detection = new ExtractOperationDetection(addedClass.getOperations(), this); ExtractOperationRefactoring refactoring = detection.check(movedMethodMapper, operation); if(refactoring != null) { this.refactorings.add(refactoring); } } } } }