mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-36447 Handle binary expression
GitOrigin-RevId: c2d54a40db1b8ad500845a18d750c3ab52a4b6ce
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3986ae8da0
commit
fd218e6170
+4
-1
@@ -38,7 +38,7 @@ internal object NoReturnValueFactory {
|
||||
val newExpression = buildNewExpression(factory, element, parent)
|
||||
|
||||
val elementToReplace = when (parent) {
|
||||
is KtParenthesizedExpression -> parent
|
||||
is KtParenthesizedExpression, is KtBinaryExpression -> parent
|
||||
else -> element
|
||||
}.let(updater::getWritable)
|
||||
|
||||
@@ -58,6 +58,9 @@ internal object NoReturnValueFactory {
|
||||
is KtParenthesizedExpression if parent.parent !is KtContainerNode -> {
|
||||
factory.createDeclaration("val _ = ${parent.text}")
|
||||
}
|
||||
is KtBinaryExpression -> {
|
||||
factory.createDeclaration("val _ = ${parent.text}")
|
||||
}
|
||||
is KtParenthesizedExpression, is KtWhenEntry, is KtContainerNode -> {
|
||||
factory.createExpression("{$baseExpressionText}")
|
||||
}
|
||||
|
||||
+5
@@ -8019,6 +8019,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryExpressions.kt")
|
||||
public void testBinaryExpressions() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/explicitlyIgnoreReturnValue/binaryExpressions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("if.kt")
|
||||
public void testIf() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/explicitlyIgnoreReturnValue/if.kt");
|
||||
|
||||
+5
@@ -9772,6 +9772,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryExpressions.kt")
|
||||
public void testBinaryExpressions() throws Exception {
|
||||
runTest("testData/quickfix/explicitlyIgnoreReturnValue/binaryExpressions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("if.kt")
|
||||
public void testIf() throws Exception {
|
||||
runTest("testData/quickfix/explicitlyIgnoreReturnValue/if.kt");
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Explicitly ignore return value" "true"
|
||||
// LANGUAGE_VERSION: 2.2
|
||||
// COMPILER_ARGUMENTS: -Xreturn-value-checker=full
|
||||
fun someFunction() {
|
||||
<caret>someFunctionValue() ?: error("failure")
|
||||
}
|
||||
fun someFunctionValue(): Int? = 1
|
||||
|
||||
// IGNORE_K1
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.NoReturnValueFactory$UnderscoreValueFix
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Explicitly ignore return value" "true"
|
||||
// LANGUAGE_VERSION: 2.2
|
||||
// COMPILER_ARGUMENTS: -Xreturn-value-checker=full
|
||||
fun someFunction() {
|
||||
<caret>val _ = someFunctionValue() ?: error("failure")
|
||||
}
|
||||
fun someFunctionValue(): Int? = 1
|
||||
|
||||
// IGNORE_K1
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.NoReturnValueFactory$UnderscoreValueFix
|
||||
Reference in New Issue
Block a user