Taking into account extracted method calls into the body of lambdas
This improvement enables the detection of refactoring
Extract Method protected changePreferences(preference CheckBox) : void extracted from protected onCreate(savedInstanceState Bundle) : void in class com.conupods.Settings.SettingsActivity
in commit
@@ -14,6 +14,7 @@ import gr.uom.java.xmi.UMLType;
import gr.uom.java.xmi.decomposition.AbstractCodeFragment;
import gr.uom.java.xmi.decomposition.AbstractCodeMapping;
import gr.uom.java.xmi.decomposition.CompositeStatementObject;
+import gr.uom.java.xmi.decomposition.LambdaExpressionObject;
import gr.uom.java.xmi.decomposition.OperationInvocation;
import gr.uom.java.xmi.decomposition.StatementObject;
import gr.uom.java.xmi.decomposition.UMLOperationBodyMapper;
@@ -142,6 +143,26 @@ public class ExtractOperationDetection {
}
}
}
+ List<LambdaExpressionObject> lambdas = statement.getLambdas();
+ for(LambdaExpressionObject lambda : lambdas) {
+ if(lambda.getBody() != null) {
+ for(OperationInvocation statementInvocation : lambda.getBody().getAllOperationInvocations()) {
+ if(!containsInvocation(operationInvocations, statementInvocation)) {
+ operationInvocations.add(statementInvocation);
+ }
+ }
+ }
+ if(lambda.getExpression() != null) {
+ Map<String, List<OperationInvocation>> methodInvocationMap = lambda.getExpression().getMethodInvocationMap();
+ for(String key : methodInvocationMap.keySet()) {
+ for(OperationInvocation statementInvocation : methodInvocationMap.get(key)) {
+ if(!containsInvocation(operationInvocations, statementInvocation)) {
+ operationInvocations.add(statementInvocation);
+ }
+ }
+ }
+ }
+ }
}
public static boolean containsInvocation(List<OperationInvocation> operationInvocations, OperationInvocation invocation) {
