Kotlin在注释处理器中获取类名

时间:2020-06-23 10:38:42

标签: android kotlin

我正在使用带有类名的注释创建注释处理器,检查名称是否为CamelCase并编写所有不使用camelcase的类。

这是编写所有这些类的函数:

private fun checkCamelVariable(classElement: TypeElement) {
    classElement.enclosedElements.filter {
        !it.simpleName.toString().isDefinedCamelCase()
    }.forEach {
        printWarning("Detected non-camelcase name: ${it.simpleName}.")
    }
}

在我的构建日志中,我得到:

警告:检测到的非大写字母名称:TAG。[WARN]请求了增量注释处理,但由于以下处理器不是增量处理器而被禁用:com.example.processor.GenerateProcessor(NON_INCREMENTAL),com.google.auto。 service.processor.AutoServiceProcessor(NON_INCREMENTAL)。

这表示我的注释有效,但无法获取类名。 在这样的地方看过:How to get rid of Incremental annotation processing requested warning?

但没有任何建议可以帮助我。

0 个答案:

没有答案
相关问题