@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity" })
	protected XExpression _generate(XSwitchExpression switchStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		final String varName;
		if (switchStatement.getDeclaredParam() != null) {
			varName = it.declareUniqueNameVariable(switchStatement.getDeclaredParam(),
					switchStatement.getDeclaredParam().getSimpleName());
		} else {
			varName = it.declareSyntheticVariable(switchStatement, "___expression"); //$NON-NLS-1$
		}
		it.openPseudoScope();
		it.append(varName).append(" = "); //$NON-NLS-1$
		generate(switchStatement.getSwitch(), it, context);
		it.newLine();
		boolean first = true;
		boolean fallThrough = false;
		for (final XCasePart caseExpression : switchStatement.getCases()) {
			if (fallThrough) {
				it.append(") or ("); //$NON-NLS-1$
			} else if (first) {
				it.append("if ("); //$NON-NLS-1$
				first = false;
			} else {
				it.append("elif ("); //$NON-NLS-1$
			}
			if (caseExpression.getTypeGuard() != null) {
				it.append("isinstance(").append(varName); //$NON-NLS-1$
				it.append(", ").append(caseExpression.getTypeGuard().getType()); //$NON-NLS-1$
				it.append(")"); //$NON-NLS-1$
				if (caseExpression.getCase() != null) {
					it.append(" and ("); //$NON-NLS-1$
					generate(caseExpression.getCase(), it, context);
					it.append(")"); //$NON-NLS-1$
					final LightweightTypeReference convertedType = getExpectedType(caseExpression.getCase());
					if (!convertedType.isType(Boolean.TYPE) && !convertedType.isType(Boolean.class)) {
						it.append(" == ").append(varName); //$NON-NLS-1$
					}
				}
			} else if (caseExpression.getCase() != null) {
				it.append("("); //$NON-NLS-1$
				generate(caseExpression.getCase(), it, context);
				it.append(")"); //$NON-NLS-1$
				final LightweightTypeReference convertedType = getExpectedType(caseExpression.getCase());
				if (!convertedType.isType(Boolean.TYPE) && !convertedType.isType(Boolean.class)) {
					it.append(" == ").append(varName); //$NON-NLS-1$
				}
			}
			fallThrough = caseExpression.isFallThrough();
			if (!fallThrough) {
				it.append("):"); //$NON-NLS-1$
				it.increaseIndentation().newLine();
				if (caseExpression.getThen() != null) {
					generate(caseExpression.getThen(), it, context);
				} else {
					it.append("pass"); //$NON-NLS-1$
				}
				it.decreaseIndentation().newLine();
			}
		}
		if (switchStatement.getDefault() != null) {
			if (first) {
				generate(switchStatement.getDefault(), it, context);
				it.newLine();
			} else {
				it.append("else:"); //$NON-NLS-1$
				it.increaseIndentation().newLine();
				generate(switchStatement.getDefault(), it, context);
				it.decreaseIndentation().newLine();
			}
		}
		it.closeScope();
		return switchStatement;
	}
@ SuppressWarnings ( { "checkstyle:npathcomplexity" , "checkstyle:cyclomaticcomplexity" } ) protected XExpression _generate ( XSwitchExpression switchStatement , IAppendable it , IExtraLanguageGeneratorContext context ) { final String varName ; if ( switchStatement . getDeclaredParam ( ) != null ) { varName = it . declareUniqueNameVariable ( switchStatement . getDeclaredParam ( ) , switchStatement . getDeclaredParam ( ) . getSimpleName ( ) ) ; } else { varName = it . declareSyntheticVariable ( switchStatement , "___expression" ) ; } it . openPseudoScope ( ) ; it . append ( varName ) . append ( " = " ) ; generate ( switchStatement . getSwitch ( ) , it , context ) ; it . newLine ( ) ; boolean first = true ; boolean fallThrough = false ; for ( final XCasePart caseExpression : switchStatement . getCases ( ) ) { if ( fallThrough ) { it . append ( ") or (" ) ; } else if ( first ) { it . append ( "if (" ) ; first = false ; } else { it . append ( "elif (" ) ; } if ( caseExpression . getTypeGuard ( ) != null ) { it . append ( "isinstance(" ) . append ( varName ) ; it . append ( ", " ) . append ( caseExpression . getTypeGuard ( ) . getType ( ) ) ; it . append ( ")" ) ; if ( caseExpression . getCase ( ) != null ) { it . append ( " and (" ) ; generate ( caseExpression . getCase ( ) , it , context ) ; it . append ( ")" ) ; final LightweightTypeReference convertedType = getExpectedType ( caseExpression . getCase ( ) ) ; if ( ! convertedType . isType ( Boolean . TYPE ) && ! convertedType . isType ( Boolean . class ) ) { it . append ( " == " ) . append ( varName ) ; } } } else if ( caseExpression . getCase ( ) != null ) { it . append ( "(" ) ; generate ( caseExpression . getCase ( ) , it , context ) ; it . append ( ")" ) ; final LightweightTypeReference convertedType = getExpectedType ( caseExpression . getCase ( ) ) ; if ( ! convertedType . isType ( Boolean . TYPE ) && ! convertedType . isType ( Boolean . class ) ) { it . append ( " == " ) . append ( varName ) ; } } fallThrough = caseExpression . isFallThrough ( ) ; if ( ! fallThrough ) { it . append ( "):" ) ; it . increaseIndentation ( ) . newLine ( ) ; if ( caseExpression . getThen ( ) != null ) { generate ( caseExpression . getThen ( ) , it , context ) ; } else { it . append ( "pass" ) ; } it . decreaseIndentation ( ) . newLine ( ) ; } } if ( switchStatement . getDefault ( ) != null ) { if ( first ) { generate ( switchStatement . getDefault ( ) , it , context ) ; it . newLine ( ) ; } else { it . append ( "else:" ) ; it . increaseIndentation ( ) . newLine ( ) ; generate ( switchStatement . getDefault ( ) , it , context ) ; it . decreaseIndentation ( ) . newLine ( ) ; } } it . closeScope ( ) ; return switchStatement ; }
Generate the given object.

@param switchStatement the switch statement.
@param it the target for the generated content.
@param context the context.
@return the statement.