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 current: PsiElement? = element
|
||||||
var suppressAtStatementAllowed = true
|
var suppressAtStatementAllowed = true
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
if (current is JetDeclaration) {
|
if (current is JetDeclaration && current !is JetMultiDeclaration) {
|
||||||
val declaration = current
|
val declaration = current
|
||||||
val kind = DeclarationKindDetector.detect(declaration)
|
val kind = DeclarationKindDetector.detect(declaration)
|
||||||
if (kind != null) {
|
if (kind != null) {
|
||||||
@@ -64,14 +64,15 @@ fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: Diagnos
|
|||||||
}
|
}
|
||||||
else if (current is JetExpression && suppressAtStatementAllowed) {
|
else if (current is JetExpression && suppressAtStatementAllowed) {
|
||||||
// Add suppress action at first statement
|
// 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,
|
actions.add(KotlinSuppressIntentionAction(current, diagnosticFactory,
|
||||||
AnnotationHostKind("statement", "", true)))
|
AnnotationHostKind(kind, "", true)))
|
||||||
suppressAtStatementAllowed = false
|
suppressAtStatementAllowed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = current.getParent()
|
current = current.parent
|
||||||
}
|
}
|
||||||
return actions
|
return actions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Suppress 'REDUNDANT_NULLABLE' for val (a, b)" "true"
|
// "Suppress 'REDUNDANT_NULLABLE' for initializer " "true"
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val (a, b) = Pair<String?<caret>?, String>("", "")
|
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() {
|
fun foo() {
|
||||||
@Suppress("REDUNDANT_NULLABLE")
|
val (a, b) = @Suppress("REDUNDANT_NULLABLE")
|
||||||
val (a, b) = Pair<String?<caret>?, String>("", "")
|
Pair<String??, String>("", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Pair<A, B>(val a: A, val b: B)
|
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() {
|
fun foo() {
|
||||||
var (a, b) = Pair<String?<caret>?, String>("", "")
|
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() {
|
fun foo() {
|
||||||
@Suppress("REDUNDANT_NULLABLE")
|
var (a, b) = @Suppress("REDUNDANT_NULLABLE")
|
||||||
var (a, b) = Pair<String?<caret>?, String>("", "")
|
Pair<String??, String>("", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Pair<A, B>(val a: A, val b: B)
|
data class Pair<A, B>(val a: A, val b: B)
|
||||||
Reference in New Issue
Block a user