Resolve type of PsiMethodCallExpression

Hi all,

I'm trying to resolve the type returned by a PsiMethodCallExpression. The getType() method returns null. For example, if I have the following expression

new JFrame().getContentPane()

I would expect getType() to return Container as JFrame.getContentPane() returns container.
Is there any way to resolve this type?

Thank you in advance!
Regards,
Christian

2 comments

Hello Christian,

I'm trying to resolve the type returned by a PsiMethodCallExpression.
The getType() method returns null. For example, if I have the
following expression

new JFrame().getContentPane()

I would expect getType() to return Container as
JFrame.getContentPane() returns container. Is there any way to resolve
this type?


Please try calling resolveMethod() and then getContainingClass() on the return
value.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Hello Dmitry,

thank you for your answer, but unfortunately, the resolveMethod() method returns null.

But I noticed that this unexpected behaviour shows only when running a test within a PsiTestCase. When running the plugin in the IDEA sandbox, all goes well.

Do you see any chance to make this also run in my test case? Is there a different environment set?

Thank you & regards,
Christian

0

Please sign in to leave a comment.