Suppress warning intention fix: now multi declaration is not a possible intention target but its initializer is, relevant test fixes
This commit is contained in:
+5
-4
@@ -54,7 +54,7 @@ fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: Diagnos
|
||||
var current: PsiElement? = element
|
||||
var suppressAtStatementAllowed = true
|
||||
while (current != null) {
|
||||
if (current is JetDeclaration) {
|
||||
if (current is JetDeclaration && current !is JetMultiDeclaration) {
|
||||
val declaration = current
|
||||
val kind = DeclarationKindDetector.detect(declaration)
|
||||
if (kind != null) {
|
||||
@@ -64,14 +64,15 @@ fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: Diagnos
|
||||
}
|
||||
else if (current is JetExpression && suppressAtStatementAllowed) {
|
||||
// Add suppress action at first statement
|
||||
if (current.getParent() is JetBlockExpression) {
|
||||
if (current.parent is JetBlockExpression || current.parent is JetMultiDeclaration) {
|
||||
val kind = if (current.parent is JetBlockExpression) "statement" else "initializer"
|
||||
actions.add(KotlinSuppressIntentionAction(current, diagnosticFactory,
|
||||
AnnotationHostKind("statement", "", true)))
|
||||
AnnotationHostKind(kind, "", true)))
|
||||
suppressAtStatementAllowed = false
|
||||
}
|
||||
}
|
||||
|
||||
current = current.getParent()
|
||||
current = current.parent
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for val (a, b)" "true"
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for initializer " "true"
|
||||
|
||||
fun foo() {
|
||||
val (a, b) = Pair<String?<caret>?, String>("", "")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for val (a, b)" "true"
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for initializer " "true"
|
||||
|
||||
fun foo() {
|
||||
@Suppress("REDUNDANT_NULLABLE")
|
||||
val (a, b) = Pair<String?<caret>?, String>("", "")
|
||||
val (a, b) = @Suppress("REDUNDANT_NULLABLE")
|
||||
Pair<String??, String>("", "")
|
||||
}
|
||||
|
||||
data class Pair<A, B>(val a: A, val b: B)
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for var (a, b)" "true"
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for initializer " "true"
|
||||
|
||||
fun foo() {
|
||||
var (a, b) = Pair<String?<caret>?, String>("", "")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for var (a, b)" "true"
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for initializer " "true"
|
||||
|
||||
fun foo() {
|
||||
@Suppress("REDUNDANT_NULLABLE")
|
||||
var (a, b) = Pair<String?<caret>?, String>("", "")
|
||||
var (a, b) = @Suppress("REDUNDANT_NULLABLE")
|
||||
Pair<String??, String>("", "")
|
||||
}
|
||||
|
||||
data class Pair<A, B>(val a: A, val b: B)
|
||||
Reference in New Issue
Block a user