I am parsing Kotlin file using `org.jetbrains.kotl...
# getting-started
i
I am parsing Kotlin file using
org.jetbrains.kotlin:kotlin-compiler:1.8.10
lib I am getting instance of
KtFile
then instance of
KtClass
and finally instance of KtNamedFunction. I can verify: • function name -
ktNamedFunction.name == "invoke"
• function visibility
ktNamedFunction.isPublic
I wonder how can I checks if this function is
operator
(or
invoke operator
) ?
Copy code
class Foo() {
    operator fun invoke(taskId: TaskId) {
        
    }
}
w
From what I understand it's only available on
KFunction
, not on
KFunction1
.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-function/
a
OP is talking about PSI, which is totally different from kotlin reflect. To answer the question, maybe
ktNamedFunction.modifierList?.hasModifier(KtTokens.OPERATOR_KEYWORD) == true
?
🙌 1
i
this is what I need thx Albert
👍 1