use of org.jetbrains.kotlin.js.translate.operation.InOperationTranslator in project kotlin by JetBrains.
the class WhenTranslator method translateRangeCondition.
@NotNull
private JsExpression translateRangeCondition(@NotNull KtWhenConditionInRange condition, @NotNull TranslationContext context) {
KtExpression patternExpression = condition.getRangeExpression();
assert patternExpression != null : "Expression pattern should have an expression: " + PsiUtilsKt.getTextWithLocation(condition);
JsExpression expressionToMatch = getExpressionToMatch();
assert expressionToMatch != null : "Range pattern is only available for 'when (C) { in ... }' expressions: " + PsiUtilsKt.getTextWithLocation(condition);
Map<KtExpression, JsExpression> subjectAliases = new HashMap<KtExpression, JsExpression>();
subjectAliases.put(whenExpression.getSubjectExpression(), expressionToMatch);
TranslationContext callContext = context.innerContextWithAliasesForExpressions(subjectAliases);
boolean negated = condition.getOperationReference().getReferencedNameElementType() == KtTokens.NOT_IN;
return new InOperationTranslator(callContext, expressionToMatch, condition.getRangeExpression(), condition.getOperationReference(), negated).translate();
}
Aggregations