mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] "Convert concatenation to template" (K2): fix false negative when first variable is nullable
^KTIJ-25483 Fixed closes https://github.com/JetBrains/intellij-community/pull/2444 GitOrigin-RevId: d94d73bc79c1e683bcb72c991dd73e8e72167c1a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a5aa4ccb0b
commit
eef148bad0
+4
-3
@@ -50,10 +50,11 @@ fun isStringPlusExpressionWithoutNewLineInOperands(expression: KtBinaryExpressio
|
||||
if (expression.getKtType()?.isString != true) return false
|
||||
val plusOperation = expression.operationReference.mainReference.resolveToSymbol() as? KtCallableSymbol
|
||||
val classContainingPlus = plusOperation?.getContainingSymbol() as? KtNamedClassOrObjectSymbol
|
||||
if (classContainingPlus == null) {
|
||||
return plusOperation?.callableIdIfNonLocal?.asSingleFqName()?.asString() == "kotlin.text.plus"
|
||||
return if (classContainingPlus != null) {
|
||||
classContainingPlus.classIdIfNonLocal?.asSingleFqName() == StandardNames.FqNames.string.toSafe()
|
||||
} else {
|
||||
plusOperation?.callableIdIfNonLocal?.asSingleFqName()?.asString() in listOf("kotlin.text.plus", "kotlin.plus")
|
||||
}
|
||||
return classContainingPlus.classIdIfNonLocal?.asSingleFqName() == StandardNames.FqNames.string.toSafe()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
@@ -2067,6 +2067,11 @@ public abstract class K2IntentionTestGenerated extends AbstractK2IntentionTest {
|
||||
runTest("../../../idea/tests/testData/intentions/convertToStringTemplate/specialCharsInCharLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithNullableVariable.kt")
|
||||
public void testStartsWithNullableVariable() throws Exception {
|
||||
runTest("../../../idea/tests/testData/intentions/convertToStringTemplate/startsWithNullableVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("stringPlusStringLiteral.kt")
|
||||
public void testStringPlusStringLiteral() throws Exception {
|
||||
runTest("../../../idea/tests/testData/intentions/convertToStringTemplate/stringPlusStringLiteral.kt");
|
||||
|
||||
+5
@@ -9608,6 +9608,11 @@ public abstract class K1IntentionTestGenerated extends AbstractK1IntentionTest {
|
||||
runTest("testData/intentions/convertToStringTemplate/specialCharsInCharLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithNullableVariable.kt")
|
||||
public void testStartsWithNullableVariable() throws Exception {
|
||||
runTest("testData/intentions/convertToStringTemplate/startsWithNullableVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("stringPlusStringLiteral.kt")
|
||||
public void testStringPlusStringLiteral() throws Exception {
|
||||
runTest("testData/intentions/convertToStringTemplate/stringPlusStringLiteral.kt");
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val foo: String? = "text"
|
||||
val bar = <caret>foo + "bar"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val foo: String? = "text"
|
||||
val bar = "${foo}bar"
|
||||
+5
@@ -686,6 +686,11 @@ public abstract class Fe10BindingIntentionTestGenerated extends AbstractFe10Bind
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/specialCharsInCharLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithNullableVariable.kt")
|
||||
public void testStartsWithNullableVariable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/startsWithNullableVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("stringPlusStringLiteral.kt")
|
||||
public void testStringPlusStringLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/stringPlusStringLiteral.kt");
|
||||
|
||||
Reference in New Issue
Block a user