From aff83087a331fd89dd5c4560bddef87950fc43ef Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 7 Dec 2015 21:11:26 +0300 Subject: [PATCH] Allow to suppress warnings at file level --- .../org/jetbrains/kotlin/psi/KtPsiFactory.kt | 8 +++ .../jetbrains/kotlin/psi/psiUtil/psiUtils.kt | 26 ++++++++ .../KotlinSuppressableWarningProblemGroup.kt | 33 ++++++---- .../quickfix/KotlinSuppressIntentionAction.kt | 65 ++++++++++++++++--- .../topLevelFunctionSuppressOnFile.kt | 3 + .../topLevelFunctionSuppressOnFile.kt.after | 5 ++ ...elFunctionSuppressOnFileOtherAnnotation.kt | 8 +++ ...tionSuppressOnFileOtherAnnotation.kt.after | 9 +++ ...pLevelFunctionSuppressOnFileWithPackage.kt | 6 ++ ...FunctionSuppressOnFileWithPackage.kt.after | 8 +++ ...LevelFunctionSuppressOnFileWithSuppress.kt | 4 ++ ...unctionSuppressOnFileWithSuppress.kt.after | 4 ++ .../unavailable/inAnnotationArgument.kt | 1 + .../forStatement/unavailable/inClassHeader.kt | 1 + .../unavailable/inDefaultArgument.kt | 1 + .../unavailable/inExpressionBody.kt | 1 + .../unavailable/inLocalValInitializer.kt | 1 + .../unavailable/inParameterType.kt | 1 + .../inParameterTypeInFunctionLiteral.kt | 1 + .../unavailable/inPropertyInitializer.kt | 1 + .../forStatement/unavailable/objectLiteral.kt | 1 + .../objectLiteralInsideExpression.kt | 1 + .../forStatement/unavailable/supretype.kt | 1 + .../idea/quickfix/QuickFixTestGenerated.java | 24 +++++++ 24 files changed, 192 insertions(+), 22 deletions(-) create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt.after create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt.after create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt.after create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt create mode 100644 idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt.after diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index cb3ab3ea38a..2fd7fbac14b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -155,6 +155,14 @@ public class KtPsiFactory(private val project: Project) { return createClass("class A {\n companion object{\n}\n}").getCompanionObjects().first() } + public fun createFileAnnotation(annotationText: String): KtAnnotationEntry { + return createFileAnnotationListWithAnnotation(annotationText).annotationEntries.first() + } + + public fun createFileAnnotationListWithAnnotation(annotationText: String) : KtFileAnnotationList { + return createFile("@file:${annotationText}").fileAnnotationList!! + } + public fun createFile(text: String): KtFile { return createFile("dummy.kt", text) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt index 50b7cc116c8..db3a00bad14 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt @@ -22,6 +22,8 @@ import com.intellij.psi.search.PsiSearchScopeUtil import com.intellij.psi.search.SearchScope import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.diagnostics.DiagnosticUtils +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtFileAnnotationList import java.util.* // NOTE: in this file we collect only LANGUAGE INDEPENDENT methods working with PSI and not modifying it @@ -312,6 +314,29 @@ public fun PsiElement.getElementTextWithContext(): String { public fun PsiElement.getTextWithLocation(): String = "'${this.getText()}' at ${DiagnosticUtils.atLocation(this)}" +fun replaceFileAnnotationList(file: KtFile, annotationList: KtFileAnnotationList): KtFileAnnotationList { + if (file.fileAnnotationList != null) { + return file.fileAnnotationList!!.replace(annotationList) as KtFileAnnotationList + } + + val beforeAnchor : PsiElement? = when { + file.packageDirective?.packageKeyword != null -> file.packageDirective!! + file.importList != null -> file.importList!! + file.declarations.firstOrNull() != null -> file.declarations.first() + else -> null + } + + if (beforeAnchor != null) { + return file.addBefore(annotationList, beforeAnchor) as KtFileAnnotationList + } + + if (file.lastChild == null) { + return file.add(annotationList) as KtFileAnnotationList + } + + return file.addAfter(annotationList, file.lastChild) as KtFileAnnotationList +} + // ----------------------------------------------------------------------------------------------------------------------------------------- operator fun SearchScope.contains(element: PsiElement): Boolean = PsiSearchScopeUtil.isInScope(this, element) @@ -320,3 +345,4 @@ public fun E.createSmartPointer(): SmartPsiElementPointer = SmartPointerManager.getInstance(getProject()).createSmartPsiElementPointer(this) public fun PsiElement.before(element: PsiElement) = textRange.endOffset <= element.textRange.startOffset + diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt index 26f090834cc..c20443dc116 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt @@ -57,20 +57,29 @@ fun createSuppressWarningActions(element: PsiElement, severity: Severity, suppre var current: PsiElement? = element var suppressAtStatementAllowed = true while (current != null) { - if (current is KtDeclaration && current !is KtDestructuringDeclaration) { - val declaration = current - val kind = DeclarationKindDetector.detect(declaration) - if (kind != null) { - actions.add(KotlinSuppressIntentionAction(declaration, suppressionKey, kind)) + when { + current is KtDeclaration && current !is KtDestructuringDeclaration -> { + val declaration = current + val kind = DeclarationKindDetector.detect(declaration) + if (kind != null) { + actions.add(KotlinSuppressIntentionAction(declaration, suppressionKey, kind)) + } + suppressAtStatementAllowed = false } - suppressAtStatementAllowed = false - } - else if (current is KtExpression && suppressAtStatementAllowed) { - // Add suppress action at first statement - if (current.parent is KtBlockExpression || current.parent is KtDestructuringDeclaration) { - val kind = if (current.parent is KtBlockExpression) "statement" else "initializer" + + current is KtExpression && suppressAtStatementAllowed -> { + // Add suppress action at first statement + if (current.parent is KtBlockExpression || current.parent is KtDestructuringDeclaration) { + val kind = if (current.parent is KtBlockExpression) "statement" else "initializer" + actions.add(KotlinSuppressIntentionAction(current, suppressionKey, + AnnotationHostKind(kind, "", true))) + suppressAtStatementAllowed = false + } + } + + current is KtFile -> { actions.add(KotlinSuppressIntentionAction(current, suppressionKey, - AnnotationHostKind(kind, "", true))) + AnnotationHostKind("file", current.name, true))) suppressAtStatementAllowed = false } } 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 467a69b2257..bf7bf40dcff 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 @@ -25,13 +25,21 @@ 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.psi.* +import org.jetbrains.kotlin.psi.psiUtil.replaceFileAnnotationList import org.jetbrains.kotlin.resolve.BindingContext -public class KotlinSuppressIntentionAction( - private val suppressAt: KtExpression, +class KotlinSuppressIntentionAction private constructor( + private val suppressAt: PsiElement, private val suppressKey: String, private val kind: AnnotationHostKind ) : SuppressIntentionAction() { + constructor(suppressAt: KtExpression, + suppressKey: String, + kind: AnnotationHostKind) : this(suppressAt as PsiElement, suppressKey, kind) + + constructor(suppressAt: KtFile, + suppressKey: String, + kind: AnnotationHostKind) : this(suppressAt as PsiElement, suppressKey, kind) override fun getFamilyName() = KotlinBundle.message("suppress.warnings.family") override fun getText() = KotlinBundle.message("suppress.warning.for", suppressKey, kind.kind, kind.name) @@ -40,15 +48,43 @@ public class KotlinSuppressIntentionAction( override fun invoke(project: Project, editor: Editor?, element: PsiElement) { val id = "\"$suppressKey\"" - if (suppressAt is KtModifierListOwner) { - suppressAtModifierListOwner(suppressAt, id) + when (suppressAt) { + is KtModifierListOwner -> + suppressAtModifierListOwner(suppressAt, id) + + is KtAnnotatedExpression -> + suppressAtAnnotatedExpression(CaretBox(suppressAt, editor), id) + + is KtExpression -> + suppressAtExpression(CaretBox(suppressAt, editor), id) + + is KtFile -> + suppressAtFile(suppressAt, id) } - else if (suppressAt is KtAnnotatedExpression) { - suppressAtAnnotatedExpression(CaretBox(suppressAt, editor), id) + } + + private fun suppressAtFile(ktFile: KtFile, id: String) { + val psiFactory = KtPsiFactory(suppressAt) + + val fileAnnotationList: KtFileAnnotationList? = ktFile.fileAnnotationList + if (fileAnnotationList == null) { + val newAnnotationList = psiFactory.createFileAnnotationListWithAnnotation(suppressAnnotationText(id, false)) + val createAnnotationList = replaceFileAnnotationList(ktFile, newAnnotationList) + ktFile.addAfter(psiFactory.createWhiteSpace(kind), createAnnotationList) + + return } - else if (suppressAt is KtExpression) { - suppressAtExpression(CaretBox(suppressAt, editor), id) + + val suppressAnnotation: KtAnnotationEntry? = findSuppressAnnotation(fileAnnotationList) + if (suppressAnnotation == null) { + val newSuppressAnnotation = psiFactory.createFileAnnotation(suppressAnnotationText(id, false)) + fileAnnotationList.add(psiFactory.createWhiteSpace(kind)) + fileAnnotationList.add(newSuppressAnnotation) as KtAnnotationEntry + + return } + + addArgumentToSuppressAnnotation(suppressAnnotation, id) } private fun suppressAtModifierListOwner(suppressAt: KtModifierListOwner, id: String) { @@ -125,11 +161,20 @@ public class KotlinSuppressIntentionAction( } } - private fun suppressAnnotationText(id: String) = "@Suppress($id)" + private fun suppressAnnotationText(id: String, withAt: Boolean = true) = "${if (withAt) "@" else ""}${KotlinBuiltIns.FQ_NAMES.suppress.shortName()}($id)" private fun findSuppressAnnotation(annotated: KtAnnotated): KtAnnotationEntry? { val context = annotated.analyze() - for (entry in annotated.getAnnotationEntries()) { + return findSuppressAnnotation(context, annotated.getAnnotationEntries()) + } + + private fun findSuppressAnnotation(annotationList: KtFileAnnotationList): KtAnnotationEntry? { + val context = annotationList.analyze() + return findSuppressAnnotation(context, annotationList.annotationEntries) + } + + private fun findSuppressAnnotation(context: BindingContext, annotationEntries: List): KtAnnotationEntry? { + for (entry in annotationEntries) { val annotationDescriptor = context.get(BindingContext.ANNOTATION, entry) if (annotationDescriptor != null && KotlinBuiltIns.isSuppressAnnotation(annotationDescriptor)) { return entry diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt new file mode 100644 index 00000000000..ee83eaf41b4 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt.after b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt.after new file mode 100644 index 00000000000..2cbd93d56c8 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt.after @@ -0,0 +1,5 @@ +@file:Suppress("REDUNDANT_NULLABLE") + +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt new file mode 100644 index 00000000000..4bc6b390f25 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +// ERROR: This annotation is not applicable to target 'file' and use site target '@file' + +@file:Deprecated("Some") + +package test + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt.after b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt.after new file mode 100644 index 00000000000..7e7991b767a --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt.after @@ -0,0 +1,9 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +// ERROR: This annotation is not applicable to target 'file' and use site target '@file' + +@file:Deprecated("Some") +@file:Suppress("REDUNDANT_NULLABLE") + +package test + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt new file mode 100644 index 00000000000..2544d31def4 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +/** Some Comment **/ + +package test + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt.after b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt.after new file mode 100644 index 00000000000..a48c58260bf --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt.after @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +/** Some Comment **/ + +@file:Suppress("REDUNDANT_NULLABLE") + +package test + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt new file mode 100644 index 00000000000..af3851c6d22 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +@file:Suppress("unused") + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt.after b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt.after new file mode 100644 index 00000000000..e95241ed62d --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt.after @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for file ${file}" "true" +@file:Suppress("unused", "REDUNDANT_NULLABLE") + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inAnnotationArgument.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inAnnotationArgument.kt index 0fd089bd058..949e953bb02 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inAnnotationArgument.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inAnnotationArgument.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'INTEGER_OVERFLOW' for fun foo +// ACTION: Suppress 'INTEGER_OVERFLOW' for file inAnnotationArgument.kt @Ann(Integer.MAX_VALUE + 1) fun foo() {} diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inClassHeader.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inClassHeader.kt index af60e795e7b..dfa849b23a0 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inClassHeader.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inClassHeader.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for class Child +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file inClassHeader.kt open class Base(s: String) class Child: Base(""!!) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inDefaultArgument.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inDefaultArgument.kt index aa47dc38422..e4502859855 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inDefaultArgument.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inDefaultArgument.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for parameter s +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file inDefaultArgument.kt fun foo(s: String = ""!!) {} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inExpressionBody.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inExpressionBody.kt index cec96edb67a..dc7d21b5fd8 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inExpressionBody.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inExpressionBody.kt @@ -1,4 +1,5 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file inExpressionBody.kt fun foo() = ""!! \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inLocalValInitializer.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inLocalValInitializer.kt index 429e511bfe3..3e8fb2d54f8 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inLocalValInitializer.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inLocalValInitializer.kt @@ -1,6 +1,7 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val bar +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file inLocalValInitializer.kt fun foo() { val bar = ""!! diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterType.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterType.kt index 8f07f10d11c..b85133e8d7d 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterType.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterType.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'REDUNDANT_NULLABLE' for fun foo // ACTION: Suppress 'REDUNDANT_NULLABLE' for parameter s +// ACTION: Suppress 'REDUNDANT_NULLABLE' for file inParameterType.kt fun foo(s: String??) {} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterTypeInFunctionLiteral.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterTypeInFunctionLiteral.kt index 16b0670d7fa..bc29cd6b7c3 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterTypeInFunctionLiteral.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inParameterTypeInFunctionLiteral.kt @@ -1,6 +1,7 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'REDUNDANT_NULLABLE' for fun foo // ACTION: Suppress 'REDUNDANT_NULLABLE' for parameter x +// ACTION: Suppress 'REDUNDANT_NULLABLE' for file inParameterTypeInFunctionLiteral.kt fun foo() { any { diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/inPropertyInitializer.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/inPropertyInitializer.kt index 65b7cfec0e2..c0a90b7a665 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/inPropertyInitializer.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/inPropertyInitializer.kt @@ -1,4 +1,5 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val foo +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file inPropertyInitializer.kt val foo = ""!! \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteral.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteral.kt index 4eb656f4f3f..39823f57bdb 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteral.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteral.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file objectLiteral.kt fun foo() { object : Base(""!!) { diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteralInsideExpression.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteralInsideExpression.kt index cc8eeafc8d5..78eced6cc48 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteralInsideExpression.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/objectLiteralInsideExpression.kt @@ -1,6 +1,7 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo // ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val a +// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for file objectLiteralInsideExpression.kt fun foo() { val a = object : Base(""!!) { diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/supretype.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/supretype.kt index aee9200f3a5..2140c5a9ffd 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/supretype.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/supretype.kt @@ -1,5 +1,6 @@ // "class com.intellij.codeInspection.SuppressIntentionAction" "false" // ACTION: Suppress 'REDUNDANT_NULLABLE' for class Child +// ACTION: Suppress 'REDUNDANT_NULLABLE' for file supretype.kt open class Base class Child: Base?>() \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 2b228ca8a91..a4ca883dcf0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -6101,6 +6101,30 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("topLevelFunctionSuppressOnFile.kt") + public void testTopLevelFunctionSuppressOnFile() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFile.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelFunctionSuppressOnFileOtherAnnotation.kt") + public void testTopLevelFunctionSuppressOnFileOtherAnnotation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileOtherAnnotation.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelFunctionSuppressOnFileWithPackage.kt") + public void testTopLevelFunctionSuppressOnFileWithPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithPackage.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelFunctionSuppressOnFileWithSuppress.kt") + public void testTopLevelFunctionSuppressOnFileWithSuppress() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionSuppressOnFileWithSuppress.kt"); + doTest(fileName); + } + @TestMetadata("topLevelFunctionUnrelatedAnnotation.kt") public void testTopLevelFunctionUnrelatedAnnotation() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/annotationPosition/topLevelFunctionUnrelatedAnnotation.kt");