Skip to content

Commit

Permalink
Final fix for issue #77
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Aug 17, 2020
1 parent cf942fd commit 3186615
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,19 @@ else if(binding.getKind() == IBinding.VARIABLE) {
Assignment fieldAssignment = finalFieldAssignmentMap.get(fieldFragment);
Assignment newFieldAssignment = extractedClassAST.newAssignment();
extractedClassRewriter.set(newFieldAssignment, Assignment.LEFT_HAND_SIDE_PROPERTY, fieldAssignment.getLeftHandSide(), null);
extractedClassRewriter.set(newFieldAssignment, Assignment.RIGHT_HAND_SIDE_PROPERTY, fieldAssignment.getRightHandSide(), null);
if(fieldAssignment.getRightHandSide() instanceof MethodInvocation) {
MethodInvocation invocation = (MethodInvocation)fieldAssignment.getRightHandSide();
SimpleName variableName = extractedClassAST.newSimpleName(invocation.resolveMethodBinding().getName());
extractedClassRewriter.set(newFieldAssignment, Assignment.RIGHT_HAND_SIDE_PROPERTY, variableName, null);
}
else if(fieldAssignment.getRightHandSide() instanceof ClassInstanceCreation) {
ClassInstanceCreation creation = (ClassInstanceCreation)fieldAssignment.getRightHandSide();
SimpleName variableName = extractedClassAST.newSimpleName(creation.resolveConstructorBinding().getName());
extractedClassRewriter.set(newFieldAssignment, Assignment.RIGHT_HAND_SIDE_PROPERTY, variableName, null);
}
else {
extractedClassRewriter.set(newFieldAssignment, Assignment.RIGHT_HAND_SIDE_PROPERTY, fieldAssignment.getRightHandSide(), null);
}
extractedClassRewriter.set(newFieldAssignment, Assignment.OPERATOR_PROPERTY, fieldAssignment.getOperator(), null);
ExpressionStatement assignmentStatement = extractedClassAST.newExpressionStatement(newFieldAssignment);
extractedClassConstructorBodyStatementsRewrite.insertLast(assignmentStatement, null);
Expand Down

0 comments on commit 3186615

Please sign in to comment.