Allow suppressing warnings for secondary constructor (KT-12627)

(cherry picked from commit 41cf868)

 #KT-12627 Fixed
This commit is contained in:
Kirill Rakhman
2016-08-14 14:23:02 +03:00
committed by Nikolay Krasko
parent 7a4d20b4cf
commit e6d76a9b71
5 changed files with 21 additions and 1 deletions
+1
View File
@@ -215,6 +215,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
- [`KT-13170`](https://youtrack.jetbrains.com/issue/KT-13170) "Declaration has platform type" inspection: by default should not be reported for platform type arguments
- [`KT-13262`](https://youtrack.jetbrains.com/issue/KT-13262) "Wrap with safe let call" quickfix produces wrong result for qualified function
- [`KT-13364`](https://youtrack.jetbrains.com/issue/KT-13364) Do not suggest creating annotations/enum classes for unresolved type parameter bounds
- [`KT-12627`](https://youtrack.jetbrains.com/issue/KT-12627) Allow warnings suppression for secondary constructor
##### New features
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.idea.quickfix.AnnotationHostKind
import org.jetbrains.kotlin.idea.quickfix.KotlinSuppressIntentionAction
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import java.util.Collections
import java.util.*
class KotlinSuppressableWarningProblemGroup(
private val diagnosticFactory: DiagnosticFactory<*>
@@ -110,6 +110,8 @@ private object DeclarationKindDetector : KtVisitor<AnnotationHostKind?, Unit?>()
override fun visitParameter(d: KtParameter, data: Unit?) = detect(d, "parameter", newLineNeeded = false)
override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor, data: Unit?) = detect(constructor, "secondary constructor of")
override fun visitObjectDeclaration(d: KtObjectDeclaration, data: Unit?): AnnotationHostKind? {
if (d.isCompanion()) return detect(d, "companion object", name = "${d.name} of ${d.getStrictParentOfType<KtClass>()?.name}")
if (d.parent is KtObjectLiteralExpression) return null
@@ -0,0 +1,5 @@
// "Suppress 'REDUNDANT_NULLABLE' for secondary constructor of C" "true"
class C {
constructor(s: String?<caret>?)
}
@@ -0,0 +1,6 @@
// "Suppress 'REDUNDANT_NULLABLE' for secondary constructor of C" "true"
class C {
@Suppress("REDUNDANT_NULLABLE")
constructor(s: String?<caret>?)
}
@@ -7476,6 +7476,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("secondaryConstructor.kt")
public void testSecondaryConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/declarationKinds/secondaryConstructor.kt");
doTest(fileName);
}
@TestMetadata("trait.kt")
public void testTrait() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/suppress/declarationKinds/trait.kt");