private List<MoveAttributeRefactoring> checkForAttributeMovesBetweenCommonClasses() { List<UMLAttribute> addedAttributes = getAddedAttributesInCommonClasses(); List<UMLAttribute> removedAttributes = getRemovedAttributesInCommonClasses(); return checkForAttributeMoves(addedAttributes, removedAttributes); }
public List<Refactoring> getRefactorings() { Set<Refactoring> refactorings = new LinkedHashSet<Refactoring>(); refactorings.addAll(getMoveClassRefactorings()); refactorings.addAll(getRenameClassRefactorings()); refactorings.addAll(identifyConvertAnonymousClassToTypeRefactorings()); refactorings.addAll(identifyExtractSuperclassRefactorings()); Map<Replacement, Set<CandidateAttributeRefactoring>> map = new LinkedHashMap<Replacement, Set<CandidateAttributeRefactoring>>(); for(UMLClassDiff classDiff : commonClassDiffList) { refactorings.addAll(classDiff.getRefactorings()); extractRenamePatterns(classDiff, map); extractRenamePatterns(classDiff, map); extractRenamePatterns(classDiff, map); extractRenamePatterns(classDiff, map); UMLClassBaseDiff diff = getUMLClassDiffWithAttribute(pattern); Set<CandidateAttributeRefactoring> set = map.get(pattern); for(CandidateAttributeRefactoring candidate : set) { UMLClassBaseDiff diff1 = getUMLClassDiffWithExistingAttributeAfter(pattern); UMLClassBaseDiff diff2 = getUMLClassDiffWithNewAttributeAfter(pattern); if(diff1 != null) { UMLAttribute a2 = diff1.findAttributeInNextClass(pattern.getAfter()); if(candidate.getOriginalVariableDeclaration().isAttribute()) { UMLClassBaseDiff originalClassDiff = getUMLClassDiff(candidate.getOriginalAttribute().getClassName()); if(originalClassDiff != null && originalClassDiff.removedAttributes.contains(candidate.getOriginalAttribute())) { ReplaceAttributeRefactoring ref = new ReplaceAttributeRefactoring(candidate.getOriginalAttribute(), a2, set);
public UMLModelDiff diff(UMLModel umlModel, Map<String, String> renamedFileHints) { UMLModelDiff modelDiff = new UMLModelDiff(); for(UMLClass umlClass : classList) { if(!umlModel.classList.contains(umlClass)) modelDiff.reportRemovedClass(umlClass); modelDiff.reportAddedClass(umlClass); modelDiff.checkForMovedClasses(renamedFileHints, umlModel.projectRoot, new UMLClassMatcher.Move()); modelDiff.checkForRenamedClasses(renamedFileHints, new UMLClassMatcher.Rename()); for(UMLGeneralization umlGeneralization : generalizationList) { if(!umlModel.generalizationList.contains(umlGeneralization)) modelDiff.reportRemovedGeneralization(umlGeneralization); modelDiff.reportAddedGeneralization(umlGeneralization); modelDiff.checkForGeneralizationChanges(); for(UMLRealization umlRealization : realizationList) { if(!umlModel.realizationList.contains(umlRealization)) modelDiff.reportRemovedRealization(umlRealization); modelDiff.reportAddedRealization(umlRealization); modelDiff.checkForRealizationChanges(); for(UMLClass umlClass : classList) { if(umlModel.classList.contains(umlClass)) { classDiff.process(); if(!classDiff.isEmpty()) modelDiff.addUMLClassDiff(classDiff);
if(className.contains(".") && isNumeric(className.substring(className.lastIndexOf(".")+1, className.length()))) { UMLClassBaseDiff umlClassDiff = getUMLClassDiff(className.substring(0, className.lastIndexOf("."))); attributes.addAll(umlClassDiff.originalClassAttributesOfType(addedOperation.getClassName())); for(UMLAnonymousClass anonymous : umlClassDiff.getOriginalClass().getAnonymousClassList()) { UMLClassBaseDiff umlClassDiff = getUMLClassDiff(className); attributes.addAll(umlClassDiff.originalClassAttributesOfType(addedOperation.getClassName())); if(!anotherAddedMethodExistsWithBetterMatchingInvocationExpression(addedOperationInvocation, addedOperation, addedOperations) && !conflictingExpression(addedOperationInvocation, addedOperation, mapper.getOperation2().variableTypeMap()) && extractAndMoveMatchCondition(operationBodyMapper, mapper)) { if(className.equals(addedOperation.getClassName())) { new ExtractOperationRefactoring(operationBodyMapper, mapper.getOperation2(), addedOperationInvocation); refactorings.add(extractOperationRefactoring); deleteAddedOperation(addedOperation); else if(isSubclassOf(className, addedOperation.getClassName())) { deleteAddedOperation(addedOperation); else if(isSubclassOf(addedOperation.getClassName(), className)) { deleteAddedOperation(addedOperation); new ExtractAndMoveOperationRefactoring(operationBodyMapper, mapper.getOperation2()); refactorings.add(extractOperationRefactoring); deleteAddedOperation(addedOperation);
UMLAttribute attributeOfExtractedClassType = attributeOfExtractedClassType(addedClass, classDiff); boolean isTestClass = addedClass.isTestClass() && classDiff.getOriginalClass().isTestClass(); if((!commonSuperType && !commonInterface && !extendsAddedClass) || attributeOfExtractedClassType != null || isTestClass) { ExtractClassRefactoring refactoring = atLeastOneCommonAttributeOrOperation(addedClass, classDiff, attributeOfExtractedClassType); if(refactoring != null) { CandidateExtractClassRefactoring candidate = new CandidateExtractClassRefactoring(classDiff, refactoring); if(candidate.innerClassExtract()) { innerClassExtract = true; detectSubRefactorings(candidate.getClassDiff(), candidate.getRefactoring().getExtractedClass(), candidate.getRefactoring().getRefactoringType()); detectSubRefactorings(candidate.getClassDiff(), candidate.getRefactoring().getExtractedClass(), candidate.getRefactoring().getRefactoringType());
private List<MoveAttributeRefactoring> checkForAttributeMovesBetweenRemovedAndAddedClasses() { List<UMLAttribute> addedAttributes = new ArrayList<UMLAttribute>(); for(UMLClass addedClass : addedClasses) { addedAttributes.addAll(addedClass.getAttributes()); } List<UMLAttribute> removedAttributes = new ArrayList<UMLAttribute>(); for(UMLClass removedClass : removedClasses) { removedAttributes.addAll(removedClass.getAttributes()); } return checkForAttributeMoves(addedAttributes, removedAttributes); }
private List<MoveAttributeRefactoring> checkForAttributeMovesIncludingRemovedClasses() { List<UMLAttribute> addedAttributes = getAddedAttributesInCommonClasses(); /*for(UMLClass addedClass : addedClasses) { addedAttributes.addAll(addedClass.getAttributes()); }*/ List<UMLAttribute> removedAttributes = getRemovedAttributesInCommonClasses(); for(UMLClass removedClass : removedClasses) { removedAttributes.addAll(removedClass.getAttributes()); } return checkForAttributeMoves(addedAttributes, removedAttributes); }
private List<MoveAttributeRefactoring> checkForAttributeMovesIncludingAddedClasses() { List<UMLAttribute> addedAttributes = getAddedAttributesInCommonClasses(); for(UMLClass addedClass : addedClasses) { addedAttributes.addAll(addedClass.getAttributes()); } List<UMLAttribute> removedAttributes = getRemovedAttributesInCommonClasses(); /*for(UMLClass removedClass : removedClasses) { removedAttributes.addAll(removedClass.getAttributes()); }*/ return checkForAttributeMoves(addedAttributes, removedAttributes); }