Skip to content

Commit

Permalink
Fix incorrectly reported Extract Variable refactoring
Browse files Browse the repository at this point in the history
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractVectoredReadTest.java
In the constructor statement
boolean isDirect = !"array".equals(bufferType);
is moved out of the lambda expression body
apache/hadoop@87fb977
  • Loading branch information
tsantalis committed Jan 2, 2025
1 parent 273991a commit 0ad32fe
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9062,11 +9062,32 @@ private boolean canBeAdded(LeafMapping minStatementMapping, Map<String, String>
}
}
}
boolean ownedByLambda1 = false;
CompositeStatementObject parent1 = minStatementMapping.getFragment1().getParent();
while(parent1 != null) {
if(parent1.getOwner().isPresent() && parent1.getOwner().get() instanceof LambdaExpressionObject) {
ownedByLambda1 = true;
}
parent1 = parent1.getParent();
}
boolean ownedByLambda2 = false;
CompositeStatementObject parent2 = minStatementMapping.getFragment2().getParent();
while(parent2 != null) {
if(parent2.getOwner().isPresent() && parent2.getOwner().get() instanceof LambdaExpressionObject) {
ownedByLambda2 = true;
}
parent2 = parent2.getParent();
}
for(Refactoring r : refactorings) {
if(r instanceof ExtractVariableRefactoring) {
ExtractVariableRefactoring extract = (ExtractVariableRefactoring)r;
if(minStatementMapping.getFragment2().getVariableDeclarations().contains(extract.getVariableDeclaration())) {
conflictingMappingFound = true;
if(ownedByLambda1 == ownedByLambda2) {
conflictingMappingFound = true;
}
else {
refactorings.remove(r);
}
break;
}
}
Expand Down

0 comments on commit 0ad32fe

Please sign in to comment.