File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
src/org/jetbrains/kotlin/test/helper/inspections Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 35
35
displayType =" STICKY_BALLOON"
36
36
key =" compiler.devkit.run_apply" />
37
37
38
+ <lang .inspectionSuppressor language =" kotlin" implementationClass =" org.jetbrains.kotlin.test.helper.inspections.UnusedDeclarationSuppressor" />
38
39
</extensions >
39
40
40
41
<extensions defaultExtensionNs =" org.jetbrains.kotlin" >
Original file line number Diff line number Diff line change
1
+ package org.jetbrains.kotlin.test.helper.inspections
2
+
3
+ import com.intellij.codeInspection.InspectionSuppressor
4
+ import com.intellij.codeInspection.SuppressQuickFix
5
+ import com.intellij.psi.PsiElement
6
+ import org.jetbrains.kotlin.idea.base.psi.KotlinPsiHeuristics
7
+ import org.jetbrains.kotlin.name.FqName
8
+ import org.jetbrains.kotlin.psi.KtAnnotated
9
+
10
+ /* *
11
+ * Suppresses the "unused declaration" inspection for declarations annotated with one of the [entryPoints] annotations.
12
+ */
13
+ class UnusedDeclarationSuppressor : InspectionSuppressor {
14
+ override fun isSuppressedFor (element : PsiElement , toolId : String ): Boolean =
15
+ toolId.lowercase() == " unused" &&
16
+ element is KtAnnotated &&
17
+ entryPoints.any { KotlinPsiHeuristics .hasAnnotation(element, it) }
18
+
19
+ override fun getSuppressActions (element : PsiElement ? , toolId : String ): Array <out SuppressQuickFix ?> =
20
+ SuppressQuickFix .EMPTY_ARRAY
21
+ }
22
+
23
+ private val entryPoints: List <FqName > = listOf (
24
+ // Compiler
25
+ " org.jetbrains.kotlin.utils.IDEAPluginsCompatibilityAPI" ,
26
+
27
+ // Standard library
28
+ " kotlin.internal.UsedFromCompilerGeneratedCode" ,
29
+ " kotlin.js.JsIntrinsic" ,
30
+ " kotlin.wasm.internal.ExcludedFromCodegen" ,
31
+ ).map(::FqName )
You can’t perform that action at this time.
0 commit comments