[uast] Relax return type on createStringLiteralExpression

Changes the return type of `createStringLiteralExpression` to account for Kotlin having polyadic string literal implementation by default. #KTIJ-27448

GitOrigin-RevId: 0797f4ea1f935ca29725f3834c535c3e60f9db36
This commit is contained in:
Bart van Helvert
2023-10-28 13:05:52 +02:00
committed by intellij-monorepo-bot
parent ad36587b52
commit d274c9c258
3 changed files with 7 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.uast.UBinaryExpression;
import org.jetbrains.uast.ULiteralExpression;
import org.jetbrains.uast.UExpression;
import org.jetbrains.uast.UastBinaryOperator;
import org.jetbrains.uast.UastUtils;
import org.jetbrains.uast.expressions.UInjectionHost;
@@ -153,8 +153,8 @@ public class I18nizeQuickFix extends AbstractI18nizeQuickFix<UInjectionHost> {
int breakIndex = offset - literalRange.getStartOffset() - 1;
String lsubstring = value.substring(0, breakIndex);
String rsubstring = value.substring(breakIndex);
ULiteralExpression left = elementFactory.createStringLiteralExpression(lsubstring, sourcePsi);
ULiteralExpression right = elementFactory.createStringLiteralExpression(rsubstring, sourcePsi);
UExpression left = elementFactory.createStringLiteralExpression(lsubstring, sourcePsi);
UExpression right = elementFactory.createStringLiteralExpression(rsubstring, sourcePsi);
if (left == null || right == null) {
return null;
}

View File

@@ -276,8 +276,9 @@ open class KotlinUastElementFactory(project: Project) : UastElementFactory {
return KotlinUCallableReferenceExpression(callableExpression, null)
}
override fun createStringLiteralExpression(text: String, context: PsiElement?): ULiteralExpression {
return KotlinStringULiteralExpression(psiFactory(context).createExpression(StringUtil.wrapWithDoubleQuote(text)), null)
override fun createStringLiteralExpression(text: String, context: PsiElement?): UExpression {
val literal = psiFactory(context).createExpression(StringUtil.wrapWithDoubleQuote(text)) as KtStringTemplateExpression
return KotlinStringTemplateUPolyadicExpression(literal, null)
}
override fun createLongConstantExpression(long: Long, context: PsiElement?): UExpression? {

View File

@@ -183,7 +183,7 @@ interface UastElementFactory {
fun createIfExpression(condition: UExpression, thenBranch: UExpression, elseBranch: UExpression?, context: PsiElement?): UIfExpression?
fun createStringLiteralExpression(text: String, context: PsiElement?): ULiteralExpression?
fun createStringLiteralExpression(text: String, context: PsiElement?): UExpression?
fun createLongConstantExpression(long: Long, context: PsiElement?): UExpression?