Curious, there doesn't appear to be a meta express...
# arrow-meta
m
Curious, there doesn't appear to be a meta expression for matching a
KtCallExpression
node. Is
KtCallExpression
is related in any way to
KtCallableReferenceExpression
? I quickly put together a branch to add a meta matcher for
String.callExpression
but noticed when I got to the
KtPsiFactory
that there is no method there for creating a
KtCallExpression
. Which leads me to believe this is not possible at the moment since PSI might not support it? Example of what I'm talking about: https://github.com/arrow-kt/arrow-meta/compare/master...mattmoore:call-expressions?diff=unified#diff-2ab9610fb1adf0fd2d58e144d4097e56R122 Perhaps there's another way to hook into
KtCallExpression
that I'm overlooking...
i
Regarding
KtCallExpression
: Below you see two examples one in a KtDotQualifiedExpression and another as part of the KtProperty. Most of the time, those are sub tree’s of different types of composite tree’s like KtExpression, KtProperty and others. What you could do if you want to create such a function is to use for instance
createExpression
and dissect the KtCallExpression from the KtExpression if there is one. But there are multiple variants to get those. If you need help, feel free to ping me.
here is the other example
Check out how
KtSimpleNameExpression
is created. One can do the same for this case https://github.com/JetBrains/kotlin/blob/66111eb9c6b63fa8f91be9fb30408e8a7be706f0/compiler/psi/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt#L330 There are also other possibilities like traversal
m
Thanks! That makes sense. 🙂 I was able to get
createExpression
working. To your point about whether I need this yet for the problem I'm working on (a plugin to implement pattern matching) I think I realize I may not need to hook on
KtCallExpression
just yet. Using the other types that are already implemented might be sufficient for now.
👌🏽 1
i
Happy to help Matt. 🙂
m
On second thought, having a scope for
KtCallExpression
may actually be what I need. I created a WIP PR as I still need to look into some further details and how they affect pattern matching. https://github.com/arrow-kt/arrow-meta/pull/648
i
Ok If you need any help feel free to continue this thread.