Skip to content

Commit

Permalink
Only run the M2ApiDetector on Kotlin files (#107)
Browse files Browse the repository at this point in the history
This isn't applicable to Java anyway, effectively resolves #106 along the way
  • Loading branch information
ZacSweers authored Apr 19, 2023
1 parent 103fc81 commit 4855bd9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.android.tools.lint.detector.api.Severity.ERROR
import com.android.tools.lint.detector.api.SourceCodeScanner
import com.android.tools.lint.detector.api.StringOption
import com.android.tools.lint.detector.api.TextFormat
import com.android.tools.lint.detector.api.isKotlin
import com.intellij.psi.PsiNamedElement
import org.jetbrains.uast.UCallExpression
import org.jetbrains.uast.UElement
Expand Down Expand Up @@ -60,8 +61,10 @@ constructor(private val allowList: StringSetLintOption = StringSetLintOption(ALL
UQualifiedReferenceExpression::class.java,
)

override fun createUastHandler(context: JavaContext) =
object : UElementHandler() {
override fun createUastHandler(context: JavaContext): UElementHandler? {
// Only applicable to Kotlin files
if (!isKotlin(context.uastFile?.lang)) return null
return object : UElementHandler() {
override fun visitCallExpression(node: UCallExpression) = checkNode(node)

override fun visitQualifiedReferenceExpression(node: UQualifiedReferenceExpression) =
Expand All @@ -81,4 +84,5 @@ constructor(private val allowList: StringSetLintOption = StringSetLintOption(ALL
}
}
}
}
}

0 comments on commit 4855bd9

Please sign in to comment.