Eliminating Rename Variable false positives, when multiple methods are extracted from the same method.
This is a fix for false positive
Rename Variable runLocal : boolean to stayLocal : boolean in method private ignoreRehashIteration(consumer Consumer<R>, supplier IteratorSupplier<R>, iteratorParallelDistribute boolean) : void in class org.infinispan.stream.impl.DistributedCacheStream
in commit
@@ -1574,11 +1574,46 @@ public abstract class UMLClassBaseDiff implements Comparable<UMLClassBaseDiff> {
mapper.addChildMapper(operationBodyMapper);
operationsToBeRemoved.add(addedOperation);
}
+ checkForInconsistentVariableRenames(mapper);
}
}
addedOperations.removeAll(operationsToBeRemoved);
}
+ private void checkForInconsistentVariableRenames(UMLOperationBodyMapper mapper) {
+ if(mapper.getChildMappers().size() > 1) {
+ Set<Refactoring> refactoringsToBeRemoved = new LinkedHashSet<Refactoring>();
+ for(Refactoring r : refactorings) {
+ if(r instanceof RenameVariableRefactoring) {
+ RenameVariableRefactoring rename = (RenameVariableRefactoring)r;
+ Set<AbstractCodeMapping> references = rename.getVariableReferences();
+ for(AbstractCodeMapping reference : references) {
+ if(reference.getFragment1().getVariableDeclarations().size() > 0 && !reference.isExact()) {
+ Set<AbstractCodeMapping> allMappingsForReference = new LinkedHashSet<AbstractCodeMapping>();
+ for(UMLOperationBodyMapper childMapper : mapper.getChildMappers()) {
+ for(AbstractCodeMapping mapping : childMapper.getMappings()) {
+ if(mapping.getFragment1().equals(reference.getFragment1())) {
+ allMappingsForReference.add(mapping);
+ break;
+ }
+ }
+ }
+ if(allMappingsForReference.size() > 1) {
+ for(AbstractCodeMapping mapping : allMappingsForReference) {
+ if(!mapping.equals(reference) && mapping.isExact()) {
+ refactoringsToBeRemoved.add(rename);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ refactorings.removeAll(refactoringsToBeRemoved);
+ }
+ }
+
public boolean isEmpty() {
return addedOperations.isEmpty() && removedOperations.isEmpty() &&
addedAttributes.isEmpty() && removedAttributes.isEmpty() &&
