Inspection and method signature

I'm creating an inspection for IDEA. In my inspection, I override buildVisitor(), return a JavaElementVisitor and implement visitMethodCallExpression:

@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {     return new JavaElementVisitor() {         @Override         public void visitMethodCallExpression(PsiMethodCallExpression expression) {             PsiJavaCodeReferenceElement ref = expression.getMethodExpression();
            ...
        }
    }
}


What I need to do is find if that reference is from an specific method call (i.e. if the method call is to java.util.Date.getTime()). I can get the class name and the method name easily enough, but I also need to get the method signature. I've found ClsMethodImpl.getSignature(), but this returns a PsiSignature object that I then have to parse, and I think this will be bad performance-wise. Is there a faster way of getting something like an original Java signature? (i.e. "com.mypackage.MyClass.searchArray([B)B"). It's easier to store an string signature than to store a complex representation for matching.

Thank you!

2 comments
Comment actions Permalink

IntelliJ IDEA does not use the JVM-style signature strings anywhere in its PSI implementation. There are some utility functions to get JVM-style signature strings, but they aren't part of any official API, and they do the same work of parsing the PsiSignature, so they would have exactly the same performance characteristics as your own implementation.

0
Comment actions Permalink

I'll continue doing it that way, thank you.

0

Please sign in to leave a comment.