So I want to get the return type of the method my cursor is in/over. That's the goal. I thought if I could get a handle to a PsiMethod I could invoke getReturnType and see what the return type is. This is exactly (a part of ) the information you get when you control+Q over an element in the editor.
I want to first find out what kind of thing the cursor is over. I can use psiFile.findElementAt and it will return the PsiElement, but unfortunately, the PsiElement is merely a PsiIdentifier and not a PsiMethod.
Some ways up in the containment hierarchy, according to the PsiViewer, a parent of this PsiIdentifer I had returned to me is a PsiMethodCallExpression. If I clambered up and got to this object, I might be able to invoke resolveMethod and get my hands on a PsiMethod.
My question is
is there an easier way to get what method (return type is actually what I am after) the cursor is under?
Is walking up the containment hierarchy and checking the type of thing you encounter along the way a typical and necessary way of programming with the Psi?
I am green with envy towards control-Q's ability to quickly get the information I covet, and wonder if there is source anyone knows that demonstrates this kind of thing?