private boolean sourceClassImportsSuperclassOfTargetClassAfterRefactoring(String sourceClassName, String targetClassName) { UMLClassBaseDiff targetClassDiff = getUMLClassDiff(targetClassName); if(targetClassDiff != null && targetClassDiff.getSuperclass() != null) { UMLClassBaseDiff superclassOfTargetClassDiff = getUMLClassDiff(targetClassDiff.getSuperclass()); if(superclassOfTargetClassDiff != null) { return sourceClassImportsTargetClassAfterRefactoring(sourceClassName, superclassOfTargetClassDiff.getNextClassName()); } } return false; }
public void process() { processInheritance(); processOperations(); processAttributes(); checkForAttributeChanges(); createBodyMappers(); processAnonymousClasses(); checkForOperationSignatureChanges(); checkForInlinedOperations(); checkForExtractedOperations(); }
/** * @return the code range of the extracted code fragment from the source method in the <b>parent</b> commit */ public CodeRange getExtractedCodeRangeFromSourceOperation() { return CodeRange.computeRange(extractedCodeFragmentsFromSourceOperation); }
private List<Refactoring> getRenameClassRefactorings() { List<Refactoring> refactorings = new ArrayList<Refactoring>(); for(UMLClassRenameDiff classRenameDiff : classRenameDiffList) { Refactoring refactoring = null; if(classRenameDiff.samePackage()) refactoring = new RenameClassRefactoring(classRenameDiff.getOriginalClass(), classRenameDiff.getRenamedClass()); else refactoring = new MoveAndRenameClassRefactoring(classRenameDiff.getOriginalClass(), classRenameDiff.getRenamedClass()); refactorings.add(refactoring); } return refactorings; }
private void generateCallTree(UMLOperation operation, CallTreeNode parent, CallTree callTree) { Set<OperationInvocation> invocations = operation.getAllOperationInvocations(); for(UMLOperation addedOperation : addedOperations) { for(OperationInvocation invocation : invocations) { if(invocation.matchesOperation(addedOperation, operation.variableTypeMap(), modelDiff)) { if(!callTree.contains(addedOperation)) { CallTreeNode node = new CallTreeNode(operation, addedOperation, invocation); parent.addChild(node); generateCallTree(addedOperation, node, callTree); } } } } }
private UMLClassBaseDiff getUMLClassDiff(String className) { for(UMLClassDiff classDiff : commonClassDiffList) { if(classDiff.matches(className)) return classDiff; } for(UMLClassMoveDiff classDiff : classMoveDiffList) { if(classDiff.matches(className)) return classDiff; } for(UMLClassMoveDiff classDiff : innerClassMoveDiffList) { if(classDiff.matches(className)) return classDiff; } for(UMLClassRenameDiff classDiff : classRenameDiffList) { if(classDiff.matches(className)) return classDiff; } return null; }
private List<MoveAttributeRefactoring> checkForAttributeMovesBetweenCommonClasses() { List<UMLAttribute> addedAttributes = getAddedAttributesInCommonClasses(); List<UMLAttribute> removedAttributes = getRemovedAttributesInCommonClasses(); return checkForAttributeMoves(addedAttributes, removedAttributes); }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getName()).append("\t"); String originalPath = pattern.getBefore().endsWith(".") ? pattern.getBefore().substring(0, pattern.getBefore().length()-1) : pattern.getBefore(); sb.append(originalPath); sb.append(" to "); String movedPath = pattern.getAfter().endsWith(".") ? pattern.getAfter().substring(0, pattern.getAfter().length()-1) : pattern.getAfter(); sb.append(movedPath); return sb.toString(); } }
public boolean contains(UMLOperation invokedOperation) { for(CallTreeNode node : getNodesInBreadthFirstOrder()) { if(node.getInvokedOperation().equals(invokedOperation)) { return true; } } return false; } }
private boolean isSourcePackageDeleted(RenamePackageRefactoring renamePackageRefactoring) { for(String deletedFolderPath : deletedFolderPaths) { String originalPath = renamePackageRefactoring.getPattern().getBefore(); //remove last . String trimmedOriginalPath = originalPath.endsWith(".") ? originalPath.substring(0, originalPath.length()-1) : originalPath; String convertedPackageToFilePath = trimmedOriginalPath.replaceAll("\\.", UMLModelASTReader.systemFileSeparator); if(deletedFolderPath.endsWith(convertedPackageToFilePath)) { return true; } } return false; }
private void deleteAddedOperation(UMLOperation operation) { UMLClassBaseDiff classDiff = getUMLClassDiff(operation.getClassName()); if(classDiff != null) classDiff.getAddedOperations().remove(operation); }
public UMLOperationBodyMapper(UMLOperation operation1, UMLOperation operation2, UMLClassBaseDiff classDiff) { this(operation1, operation2); this.classDiff = classDiff; this.modelDiff = classDiff.getModelDiff(); }
public void setArgumentizedString1(String string) { this.argumentizedString1 = string; this.rawDistance = StringDistance.editDistance(this.argumentizedString1, this.argumentizedString2); } public int getRawDistance() {
private static int totalOccurrences(Set<CandidateAttributeRefactoring> candidates) { int totalCount = 0; for(CandidateAttributeRefactoring candidate : candidates) { totalCount += candidate.getOccurrences(); } return totalCount; }
public boolean containsExtractOperationRefactoring(UMLOperation extractedOperation) { if(classDiff != null) { return classDiff.containsExtractOperationRefactoring(operation1, extractedOperation); } return false; }
public RenamePattern reverse() { return new RenamePattern(after, before); } }
private UMLClassBaseDiff getUMLClassDiff(UMLType type) { for(UMLClassDiff classDiff : commonClassDiffList) { if(classDiff.matches(type)) return classDiff; } for(UMLClassMoveDiff classDiff : classMoveDiffList) { if(classDiff.matches(type)) return classDiff; } for(UMLClassMoveDiff classDiff : innerClassMoveDiffList) { if(classDiff.matches(type)) return classDiff; } for(UMLClassRenameDiff classDiff : classRenameDiffList) { if(classDiff.matches(type)) return classDiff; } return null; }
/** * @return the code range of the inlined code fragment in the target method in the <b>child</b> commit */ public CodeRange getInlinedCodeRangeInTargetOperation() { return CodeRange.computeRange(inlinedCodeFragmentsInTargetOperation); }
/** * @return the code range of the extracted code fragment to the extracted method in the <b>child</b> commit */ public CodeRange getExtractedCodeRangeToExtractedOperation() { return CodeRange.computeRange(extractedCodeFragmentsToExtractedOperation); }
/** * @return the code range of the inlined code fragment from the inlined method in the <b>parent</b> commit */ public CodeRange getInlinedCodeRangeFromInlinedOperation() { return CodeRange.computeRange(inlinedCodeFragmentsFromInlinedOperation); }