Simple Inspection Tool Problem
Hi guys,
I'm writing a simple custom inspection tool using BaseJavaLocalInspectionTool for the basis.
So far all is well, I create a JavaElementVisitor and register problems as required, but what I've been struggling
with is this:
We want to disable unused method warning when we know that this method will be called via reflection.
In fact I even have annotation in the same class that holds method name.
What would be the right way to suppress default inspection or do some other trick to make it happen?
I can't figure out what to do to PsiMethod, nothing I tried so far worked :(
Please sign in to leave a comment.
If someone could suggest how to accomplish this alternative fix it would be good.
@SomeAnnotation(method = "foo")
<modifiers> foo()
{
}
I want to create a reference from <foo()> to <method = "foo">. I can make a reference the other way - from annotation to method, but not backwards.
Hello Vadim,
The Java PSI doesn't support adding references to arbitrary elements, as
it could break the semantics of many of IDEA's own operations.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hello Vadim,
See the ImplicitUsageProvider API.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hehe, I see... had to find out the hard way :) At least now it's clear why my attempts were futle.
Thanks for clearing that up
Yep, that works! Cheers man!
Hi Dmitry,
Thanks again for your help!
Didn't want to create another thread for what is probably a small issue.
Suppose we're examining annotation @SomeAnnotation(foo = "bar"),
I'm interested in the value of parameter foo. So far I only thought of the case where foo is assigned from a string literal directly.
But I can't seem to be able to resolve value of the following @SomeAnnotation(foo = SomeClass.NestedClass.....StaticVariable)
Could you point me to the right direction?
Ok, to answer my own question: this works .resolve().getInitializer()