diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt index 78bbe329aac..2495218acfe 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt @@ -23,7 +23,6 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.util.PsiPrecedences import org.jetbrains.kotlin.idea.util.addAnnotation import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.replaceFileAnnotationList @@ -90,7 +89,7 @@ class KotlinSuppressIntentionAction private constructor( return } - + addArgumentToSuppressAnnotation(suppressAnnotation, id) } @@ -109,10 +108,8 @@ class KotlinSuppressIntentionAction private constructor( val suppressAt = caretBox.expression assert(suppressAt !is KtDeclaration) { "Declarations should have been checked for above" } - val parentheses = PsiPrecedences.getPrecedence(suppressAt) > PsiPrecedences.PRECEDENCE_OF_PREFIX_EXPRESSION val placeholderText = "PLACEHOLDER_ID" - val inner = if (parentheses) "($placeholderText)" else placeholderText - val annotatedExpression = KtPsiFactory(suppressAt).createExpression(suppressAnnotationText(id) + "\n" + inner) + val annotatedExpression = KtPsiFactory(suppressAt).createExpression(suppressAnnotationText(id) + "\n" + placeholderText) val copy = suppressAt.copy()!! @@ -181,4 +178,4 @@ private class CaretBox( if (editor == null) return editor.caretModel.moveToOffset(copy.textOffset + offsetInExpression) } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/suppress/forStatement/andAnd.kt.after b/idea/testData/quickfix/suppress/forStatement/andAnd.kt.after index 73f98e2d3ab..8b738bf71cc 100644 --- a/idea/testData/quickfix/suppress/forStatement/andAnd.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/andAnd.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (false!! && true) + false!! && true } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/as.kt.after b/idea/testData/quickfix/suppress/forStatement/as.kt.after index 4053b51fcad..89b16b89cc5 100644 --- a/idea/testData/quickfix/suppress/forStatement/as.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/as.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (""!! as String) + ""!! as String } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/asSafe.kt.after b/idea/testData/quickfix/suppress/forStatement/asSafe.kt.after index 4f18186c29d..bdb24ca4de6 100644 --- a/idea/testData/quickfix/suppress/forStatement/asSafe.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/asSafe.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (""!! as? String) + ""!! as? String } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/assign.kt b/idea/testData/quickfix/suppress/forStatement/assign.kt index ced26139263..439d4526c5e 100644 --- a/idea/testData/quickfix/suppress/forStatement/assign.kt +++ b/idea/testData/quickfix/suppress/forStatement/assign.kt @@ -1,5 +1,4 @@ // "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true" -// ERROR: Assignments are not expressions, and only expressions are allowed in this context fun foo() { var x = 0 diff --git a/idea/testData/quickfix/suppress/forStatement/assign.kt.after b/idea/testData/quickfix/suppress/forStatement/assign.kt.after index 8c27f33a52a..a1b67ca5610 100644 --- a/idea/testData/quickfix/suppress/forStatement/assign.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/assign.kt.after @@ -1,8 +1,7 @@ // "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true" -// ERROR: Assignments are not expressions, and only expressions are allowed in this context fun foo() { var x = 0 @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (x = 1!!) + x = 1!! } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/elvis.kt.after b/idea/testData/quickfix/suppress/forStatement/elvis.kt.after index 08a17b68106..98453f88c60 100644 --- a/idea/testData/quickfix/suppress/forStatement/elvis.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/elvis.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! ?: 0) + 1!! ?: 0 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/eqEq.kt.after b/idea/testData/quickfix/suppress/forStatement/eqEq.kt.after index ae8ffde8d5f..ee26b4098a1 100644 --- a/idea/testData/quickfix/suppress/forStatement/eqEq.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/eqEq.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! == 2) + 1!! == 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/in.kt.after b/idea/testData/quickfix/suppress/forStatement/in.kt.after index 842e732daa2..92145176bdd 100644 --- a/idea/testData/quickfix/suppress/forStatement/in.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/in.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! in (1..2)) + 1!! in (1..2) } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/infix.kt.after b/idea/testData/quickfix/suppress/forStatement/infix.kt.after index 0fe0d0a2b83..a042f030549 100644 --- a/idea/testData/quickfix/suppress/forStatement/infix.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/infix.kt.after @@ -4,5 +4,5 @@ infix fun Int.add(other: Int) = this + other fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! add 2) + 1!! add 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/is.kt.after b/idea/testData/quickfix/suppress/forStatement/is.kt.after index 2843df4101b..d049b81e619 100644 --- a/idea/testData/quickfix/suppress/forStatement/is.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/is.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (""!! is String) + ""!! is String } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/less.kt.after b/idea/testData/quickfix/suppress/forStatement/less.kt.after index 2a8373b3264..282d7a05cc4 100644 --- a/idea/testData/quickfix/suppress/forStatement/less.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/less.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! < 2) + 1!! < 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/mul.kt.after b/idea/testData/quickfix/suppress/forStatement/mul.kt.after index 4ea2ba1fb0d..8c67bf45783 100644 --- a/idea/testData/quickfix/suppress/forStatement/mul.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/mul.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! * 2) + 1!! * 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/orOr.kt.after b/idea/testData/quickfix/suppress/forStatement/orOr.kt.after index 2cb37673af8..3b62bce84ee 100644 --- a/idea/testData/quickfix/suppress/forStatement/orOr.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/orOr.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (false!! || true) + false!! || true } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/plus.kt.after b/idea/testData/quickfix/suppress/forStatement/plus.kt.after index e5716cac38d..6c944cd308a 100644 --- a/idea/testData/quickfix/suppress/forStatement/plus.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/plus.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! + 2) + 1!! + 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/range.kt.after b/idea/testData/quickfix/suppress/forStatement/range.kt.after index 298bbeecb94..497cbccf733 100644 --- a/idea/testData/quickfix/suppress/forStatement/range.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/range.kt.after @@ -2,5 +2,5 @@ fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! .. 2) + 1!! .. 2 } \ No newline at end of file