Skip to content

Commit

Permalink
Fix warnings (#69)
Browse files Browse the repository at this point in the history
* Fix warnings

* Fix warnings
  • Loading branch information
drawers authored Oct 27, 2024
1 parent 19ed43d commit d6047db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = listOf("Alphabetical")

Expand Down Expand Up @@ -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<UClass>(strict = true) ?: return
val annotatedClass =
annotationInfo.annotation.getParentOfType<UClass>() ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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<UClass>() ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -36,9 +36,11 @@ fun printLetters() {
}

object Meal {
@Suppress("UNUSED_PARAMETER")
fun tastyListOf(vararg s: String) = listOf<String>()
}

class Portion {
@Suppress("UNUSED_PARAMETER")
fun tastyListOf(vararg s: String) = listOf<String>()
}

0 comments on commit d6047db

Please sign in to comment.