From d6047db2f3b5a5dde0792f1f2b70e75b346a405b Mon Sep 17 00:00:00 2001 From: David Rawson Date: Mon, 28 Oct 2024 08:47:16 +1300 Subject: [PATCH] Fix warnings (#69) * Fix warnings * Fix warnings --- .../github/drawers/abecedary/lint/EnumEntryOrderDetector.kt | 6 ++---- .../drawers/abecedary/lint/SealedSubtypeOrderDetector.kt | 6 +++--- .../main/java/io/github/drawers/abecedary/sample/Example.kt | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/EnumEntryOrderDetector.kt b/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/EnumEntryOrderDetector.kt index 7e43e53..c29a61a 100644 --- a/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/EnumEntryOrderDetector.kt +++ b/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/EnumEntryOrderDetector.kt @@ -18,11 +18,10 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import org.jetbrains.uast.UClass import org.jetbrains.uast.UElement +import org.jetbrains.uast.UEnumConstant import org.jetbrains.uast.getParentOfType -import org.jetbrains.uast.kotlin.KotlinUEnumConstant import java.util.EnumSet -@Suppress("UnstableApiUsage") class EnumEntryOrderDetector : Detector(), SourceCodeScanner { override fun applicableAnnotations(): List = listOf("Alphabetical") @@ -57,14 +56,13 @@ class EnumEntryOrderDetector : Detector(), SourceCodeScanner { classToEnumConstants.clear() } - @Suppress("UnstableApiUsage") override fun visitAnnotationUsage( context: JavaContext, element: UElement, annotationInfo: AnnotationInfo, usageInfo: AnnotationUsageInfo, ) { - val enumConstant = element as? KotlinUEnumConstant ?: return + val enumConstant = element as? UEnumConstant ?: return val enumParent = enumConstant.getParentOfType(strict = true) ?: return val annotatedClass = annotationInfo.annotation.getParentOfType() ?: return diff --git a/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/SealedSubtypeOrderDetector.kt b/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/SealedSubtypeOrderDetector.kt index 56a110b..6ffe477 100644 --- a/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/SealedSubtypeOrderDetector.kt +++ b/abecedary-lint/src/main/java/io/github/drawers/abecedary/lint/SealedSubtypeOrderDetector.kt @@ -17,8 +17,8 @@ import com.android.tools.lint.detector.api.SourceCodeScanner import com.intellij.psi.PsiClass import org.jetbrains.uast.UClass import org.jetbrains.uast.UElement +import org.jetbrains.uast.UTypeReferenceExpression import org.jetbrains.uast.getParentOfType -import org.jetbrains.uast.kotlin.KotlinUTypeReferenceExpression import java.util.EnumSet class SealedSubtypeOrderDetector : Detector(), SourceCodeScanner { @@ -53,7 +53,7 @@ class SealedSubtypeOrderDetector : Detector(), SourceCodeScanner { classToSealedSubTypes.clear() } - @Suppress("UnstableApiUsage", "ktlint:standard:no-consecutive-comments") + @Suppress("ktlint:standard:no-consecutive-comments") override fun visitAnnotationUsage( context: JavaContext, element: UElement, @@ -74,7 +74,7 @@ class SealedSubtypeOrderDetector : Detector(), SourceCodeScanner { */ // `Fruit` in the example - val typeReference = element as? KotlinUTypeReferenceExpression ?: return + val typeReference = element as? UTypeReferenceExpression ?: return // `Banana` in the example val sealedSubType = typeReference.getParentOfType() ?: return diff --git a/abecedary-sample/src/main/java/io/github/drawers/abecedary/sample/Example.kt b/abecedary-sample/src/main/java/io/github/drawers/abecedary/sample/Example.kt index 7e739be..fe6465f 100644 --- a/abecedary-sample/src/main/java/io/github/drawers/abecedary/sample/Example.kt +++ b/abecedary-sample/src/main/java/io/github/drawers/abecedary/sample/Example.kt @@ -19,9 +19,9 @@ enum class Fruit(override val id: Int) : Identifiable { } sealed class Vegetable : Edible { - object Carrot : Vegetable() + data object Carrot : Vegetable() - object Daikon : Vegetable() + data object Daikon : Vegetable() } val letters = @Alphabetical listOf("a", "b", "c") @@ -36,9 +36,11 @@ fun printLetters() { } object Meal { + @Suppress("UNUSED_PARAMETER") fun tastyListOf(vararg s: String) = listOf() } class Portion { + @Suppress("UNUSED_PARAMETER") fun tastyListOf(vararg s: String) = listOf() }