return super.visitSwitchStatement(node, data);
}
@Override
public Void visitAssignmentExpression(final AssignmentExpression node, final Void data) {
final TypeDefinition currentType = context.getCurrentType();
final MethodDefinition currentMethod = context.getCurrentMethod();
if (_isSwitchMapWrapper &&
currentType != null &&
currentMethod != null &&
currentMethod.isTypeInitializer()) {
final Expression left = node.getLeft();
final Expression right = node.getRight();
if (left instanceof IndexerExpression &&
right instanceof PrimitiveExpression) {
String mapName = null;
final Expression array = ((IndexerExpression) left).getTarget();
final Expression argument = ((IndexerExpression) left).getArgument();
if (array instanceof MemberReferenceExpression) {
mapName = ((MemberReferenceExpression) array).getMemberName();
}
else if (array instanceof IdentifierExpression) {
mapName = ((IdentifierExpression) array).getIdentifier();
}
if (mapName == null || !mapName.startsWith("$SwitchMap$")) {
return super.visitAssignmentExpression(node, data);
}
if (!(argument instanceof InvocationExpression)) {
return super.visitAssignmentExpression(node, data);
}
final InvocationExpression invocation = (InvocationExpression) argument;
final Expression invocationTarget = invocation.getTarget();
if (!(invocationTarget instanceof MemberReferenceExpression)) {
return super.visitAssignmentExpression(node, data);
}
final MemberReferenceExpression memberReference = (MemberReferenceExpression) invocationTarget;
final Expression memberTarget = memberReference.getTarget();
if (!(memberTarget instanceof MemberReferenceExpression) || !"ordinal".equals(memberReference.getMemberName())) {
return super.visitAssignmentExpression(node, data);
}
final MemberReferenceExpression outerMemberReference = (MemberReferenceExpression) memberTarget;
final Expression outerMemberTarget = outerMemberReference.getTarget();
if (!(outerMemberTarget instanceof TypeReferenceExpression)) {
return super.visitAssignmentExpression(node, data);
}
final String enclosingType = currentType.getInternalName();
SwitchMapInfo info = _switchMaps.get(enclosingType);
if (info == null) {
_switchMaps.put(enclosingType, info = new SwitchMapInfo(enclosingType));