Finding PsiTypeElement from PsiReferenceExpression

Hi, I was wondering if there is an easy way to retrieve a PsiTypeElement from PsiReferenceExpression class.

In the example below I would like to retrieve the type of the variable t in the for loop having an instance of the object of PsiReferenceExpression.

PsiReferenceExpression.png

And I would like to get PsiTypeElement, mainly it's value which is "int".
}psitypeelement.png
Thanks in advance.

2 comments

The first thing I would suggest is to install the plugin PsiViewer from the plugin repositoiry.

2014-05-10_20-45-24.png
I show the psi tree for the variable "files"
2014-05-10_20-44-57.png
In the attribute inspector, I can see the type property is exposed by the PsiReferenceExpression.
2014-05-10_20-45-04.png

0

Thank you Jon, it was very helpful

0

Please sign in to leave a comment.