PsiMethodCallExpression - checking parameter instance

With a PsiMethodCallExpression, is there a way to find the expressions
used as parameters to that method call? Can you interrogate the
parameters instances to see if any of the objects is the same instance
(not just same type) as the containing class? In other words, I want to
identify whether the method call is using 'this' as a parameter as, for
example, here where I want to pinpoint the first addInstance but skip
the second:
class Test {
public void method() {
Utility.addInstance(this);
Utility.addInstance(new Test());
}
}
If there isn't a way from PsiMethodCallExpression, is there an alternative?

TIA,
Jon

2 comments
Comment actions Permalink

getArgumentList() contains PsiThisExpression

Jon Steelman wrote:

With a PsiMethodCallExpression, is there a way to find the expressions
used as parameters to that method call? Can you interrogate the
parameters instances to see if any of the objects is the same instance
(not just same type) as the containing class? In other words, I want to
identify whether the method call is using 'this' as a parameter as, for
example, here where I want to pinpoint the first addInstance but skip
the second:
class Test {
public void method() {
Utility.addInstance(this);
Utility.addInstance(new Test());
}
}
If there isn't a way from PsiMethodCallExpression, is there an alternative?

TIA,
Jon



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Thanks!

Maxim Mossienko wrote:

getArgumentList() contains PsiThisExpression

Jon Steelman wrote:

>> With a PsiMethodCallExpression, is there a way to find the expressions
>> used as parameters to that method call? Can you interrogate the
>> parameters instances to see if any of the objects is the same instance
>> (not just same type) as the containing class? In other words, I want
>> to identify whether the method call is using 'this' as a parameter as,
>> for example, here where I want to pinpoint the first addInstance but
>> skip the second:
>> class Test {
>> public void method() {
>> Utility.addInstance(this);
>> Utility.addInstance(new Test());
>> }
>> }
>> If there isn't a way from PsiMethodCallExpression, is there an
>> alternative?

0

Please sign in to leave a comment.