Bryan Herbst

    Bryan Herbst

    1 year ago
    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
    Sample of my
    UElementHandler
    I’m using to get the method and package names:
    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.