Skip to content

Commit

Permalink
Enable detection of Extract Variable
Browse files Browse the repository at this point in the history
merged : MergedAnnotation<?> in method public findAnnotationDeclaringClassForTypes(annotationTypes List<Class<? extends Annotation>>, clazz Class<?>) : Class<?> from class org.springframework.core.annotation.AnnotationUtils
in commit
spring-projects/spring-framework@c531a8a
  • Loading branch information
tsantalis committed Dec 19, 2024
1 parent 240ad10 commit 69d7bc8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,22 @@ else if(after.startsWith("()" + JAVA.LAMBDA_ARROW + variableName + ".")) {
}
}
}
else if(after.startsWith(variableName + " ") && initializer != null) {
if(initializer.toString().contains(before)) {
ExtractVariableRefactoring ref = new ExtractVariableRefactoring(declaration, operation1, operation2, insideExtractedOrInlinedMethod);
List<LeafExpression> subExpressions = getFragment1().findExpression(before);
for(LeafExpression subExpression : subExpressions) {
LeafMapping leafMapping = new LeafMapping(subExpression, initializer, operation1, operation2);
ref.addSubExpressionMapping(leafMapping);
}
processExtractVariableRefactoring(ref, refactorings);
checkForNestedExtractVariable(ref, refactorings, nonMappedLeavesT2, insideExtractedOrInlinedMethod);
//if(identical()) {
identicalWithExtractedVariable = true;
//}
return;
}
}
if(variableName.equals(after) && initializer != null) {
checkForAliasedVariable(initializer, replacement, nonMappedLeavesT2, classDiff, insideExtractedOrInlinedMethod);
if(initializer.toString().equals(before) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception {
GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl();
TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue());
RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test);
test.assertExpectationsWithGitHubAPI(12362, 20, 232);
test.assertExpectationsWithGitHubAPI(12363, 20, 232);
}
}
7 changes: 7 additions & 0 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -86283,6 +86283,13 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Extract Variable",
"description": "Extract Variable resolveToCallSite : boolean in method public resolve() : PsiElement from class org.intellij.erlang.psi.impl.ErlangFunctionReferenceImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}],
"refDiffExecutionTime": 964
}, {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/oracle/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bf35b533f067b51d4c373c5e5124d88525db99f3, 19, 0, 0
6c59050b8b03adf6d8043f3fb7add0496f447edf, 3, 0, 0
e068eb7f484f24dee285d29b8a910d9019592020, 4, 0, 0
07c26a3a1dd6fcc2494c2d755ee5a2753e0df87c, 2, 0, 0
3855f0ca82795f7481b34342c7d9e5644a1d42c3, 4, 0, 0
3855f0ca82795f7481b34342c7d9e5644a1d42c3, 5, 0, 0
5d1a70a4d32ac4c96a32535c68c69b20288d8968, 5, 0, 0
182f4d1174036417aad9d6db908ceaf64234fd5f, 18, 0, 0
6abc40ed4850d74ee6c155f5a28f8b34881a0284, 8, 0, 0
Expand Down

0 comments on commit 69d7bc8

Please sign in to comment.