I am developing a plugin for Clion (C++) that needs to access caller parameter name, e.g. if a function is declared:
void fun(int a);
and called
fun(42);
when the intent is invoked on 42
PsiElement
it should get the corresponding parameter name, "a"
in this case.
In a similar plugin for Intellij (Java), I get the parameter name with PsiCallExpression.resolveMethod()
which contains the list of parameters. However, I cannot figure out how to do this in a Clion plugin. I can get a reference of a corresponding OCCallExpression
, but it does not seem to contain a reference to the declared function. I tried to play around with ReferencesSearch.search()
, but it did not find the declaration of the function.
At the same time, the IDE itself displays all the parameter name hints:
so I suppose it must be possible.
How can I get the parameter name for a given caller argument expression?
Please, look at InlayParameterHintsExtension.forLanguage(OCLanguage.getInstance())
and InlayParameterHintsProvider.getParameterHints