final Expression left = node.getLeft();
final Expression right = node.getRight();
if (left instanceof MemberReferenceExpression) {
if (right instanceof IdentifierExpression) {
final Variable variable = right.getUserData(Keys.VARIABLE);
if (variable == null || !variable.isParameter()) {
return null;
}
final MemberReferenceExpression memberReference = (MemberReferenceExpression) left;
final MemberReference member = memberReference.getUserData(Keys.MEMBER_REFERENCE);
if (member instanceof FieldReference &&
memberReference.getTarget() instanceof ThisReferenceExpression) {
final FieldDefinition resolvedField = ((FieldReference) member).resolve();
if (resolvedField != null && resolvedField.isSynthetic()) {
final ParameterDefinition parameter = variable.getOriginalParameter();
final int parameterIndex = parameter.getPosition();
if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
final Expression argument = _originalArguments.get(parameterIndex);
if (argument != null) {
_nodesToRemove.add(argument);
}
if (argument instanceof ThisReferenceExpression) {
//
// Don't replace outer class references; they will be rewritten later.
//
markConstructorParameterForRemoval(node, parameter);
return null;
}
_parametersToRemove.add(parameter);
final String fullName = member.getFullName();
if (!hasSideEffects(argument)) {
_replacements.put(fullName, argument);
}
else {
context.getForcedVisibleMembers().add(resolvedField);
_initializers.put(fullName, argument);
}
if (node.getParent() instanceof ExpressionStatement) {
_nodesToRemove.add(node.getParent());
}
markConstructorParameterForRemoval(node, parameter);
}
}
else if (_baseConstructorCalled &&
resolvedField != null &&
context.getCurrentMethod().isConstructor() &&
(!context.getCurrentMethod().isSynthetic() ||
context.getSettings().getShowSyntheticMembers())) {
final MemberReferenceExpression leftMemberReference = (MemberReferenceExpression) left;
final MemberReference leftMember = leftMemberReference.getUserData(Keys.MEMBER_REFERENCE);
final Variable rightVariable = right.getUserData(Keys.VARIABLE);
if (rightVariable.isParameter()) {
final ParameterDefinition parameter = variable.getOriginalParameter();
final int parameterIndex = parameter.getPosition();
if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
final Expression argument = _originalArguments.get(parameterIndex);