https://kotlinlang.org logo
b

Bryan Herbst

10/29/2020, 7:46 PM
Are there recommendations for working with Composable functions in lint? Right now I’m trying to register a custom lint issue on a call to a Composable, but since the method names can be re-written (e.g.
Button
to
Button-bpaW8jA
) it is a little tricker to find the right Composables
😬 1
Sample of my
UElementHandler
I’m using to get the method and package names:
Copy code
override fun visitCallExpression(node: UCallExpression) {
  val method = node.resolve()
  val methodPackage = (method?.containingFile as? PsiJavaFile)?.packageName ?: return

  // method.name resolves to "Button-bpaW8jA"
  // methodPackage correctly resolves to "androidx.compose.material"
}
Of course I could just split the method name on the
-
character, but that doesn’t sound ideal.
3 Views