Benefits of implementing specific method / field inspection methods?

At first I assumed using checkMethod and so on would give performance improvements
because only methods whose semantics may have changed would be re-inspected.
However, it appears that my inspection is being run on each method in the
class, no matter how small the change is.

So I wonder, are there any hidden benefits to implementing the method and
field inspections, or are they there for convenience?


10 comments
Comment actions Permalink

It can't possibly be for convenience, as they are actually incredibly inconvenient. Knowing which ones to implement and how so as to prevent inspections from being multiply reported has been a major hassle. If there's no performance benefit, I'd be tempted to rip all of my calls to those out and replace them with the new checkFile() call.

--Dave Griffith

0
Comment actions Permalink


Now that I think about it, I should probably implement checkFile() anyway. That way, inspections will work in JSP scriptlets. Currently they don't, but only because there's no class/method/field to hang an inspection call off of. Hell.

--Dave Griffith

0
Comment actions Permalink

Dave, you'll be suprised, but THERE IS a (synthetic) class for jsp
scriptlets as well as for declarations. Sounds weird,
but that's how our new implementation of jsp works:)

Eugene.

"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:28013702.1115556729798.JavaMail.itn@is.intellij.net...
>

Now that I think about it, I should probably implement checkFile() anyway.

That way, inspections will work in JSP scriptlets. Currently they don't,
but only because there's no class/method/field to hang an inspection call
off of. Hell.
>

--Dave Griffith



0
Comment actions Permalink


I just found that out when I tried testing some of 'em. Serves me right for not using JSPs on a daily basis. How long has this been the case? Since precisely none of my inspections were designed with the thought they might be used outside of a real java file, I've either been incredibly lucky about things just working, or I'm about to be hit with a billion stack-traces from JSP authors if you've just enabled that path.

Note to PsiViewer authors: Is there any possibility that this synthetic PsiClass might be made to live in the PsiViewer tree for the JSP file? It's very disconcerting to be able to see the scriplet's contents in PsiViewer, but not be able to navigate the tree to see their context. First call on three JSP-related inspections to whoever on the PsiViewer team implements this.

--Dave Griffith

0
Comment actions Permalink


"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:33334704.1115579968178.JavaMail.itn@is.intellij.net...
>

I just found that out when I tried testing some of 'em. Serves me right

for not using JSPs on a daily basis. How long has this been the case?
Since precisely none of my inspections were designed with the thought they
might be used outside of a real java file, I've either been incredibly lucky
about things just working, or I'm about to be hit with a billion
stack-traces from JSP authors if you've just enabled that path.

Dave, I would say probably the first is true. Since all IDEA inspections,
refactorings etc. stuff was also designed in these assumptions, we had to be
cautious when introducing this new psi structure to jsp. So in general if
your inspections work for plain java, they will continue working for jsp as
well. Of course some of them would become meaningless, but that's just
another story.

Eugene.


0
Comment actions Permalink

BTW, is there a blessed way of telling when when a given PSIElement is in one of these synthetic JSP classes? I've got any number of inspections buffered which only make sense in JSP scriptlet context (or in scriptlet+servlet), if I had an easy way of testing that.

--Dave Griffith

0
Comment actions Permalink

Do you really need to test for being inside scriptlet or testing
getContainingFile() instanceof JspFile will also do? (This is true for jspx
also)
Determining script context is now impossible from openapi, but if you really
need it, we'll think something out:)

Eugene.

"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:19702125.1115638014754.JavaMail.itn@is.intellij.net...

BTW, is there a blessed way of telling when when a given PSIElement is in

one of these synthetic JSP classes? I've got any number of inspections
buffered which only make sense in JSP scriptlet context (or in
scriptlet+servlet), if I had an easy way of testing that.
>

--Dave Griffith



0
Comment actions Permalink

I'm pretty sure I don't need the script context for any of the inspections I'm thinking of. If I do, I'll let you know. If you say (getContainingFile() instanceof JspFile) works, I think I'm good.

Back on topic, I'm pretty sure Keith and I would still like an official JB answer to his original question. While you're in the neighborhood...

--Dave

0
Comment actions Permalink


"Keith Lea" <keith@cs.oswego.edu> wrote in message
news:301658632511230333008304@news.jetbrains.com...

At first I assumed using checkMethod and so on would give performance

improvements

because only methods whose semantics may have changed would be

re-inspected.

However, it appears that my inspection is being run on each method in the
class, no matter how small the change is.

No, this should not happen. When you type e.g. in method body, only the
method itself should be rechecked.
If this is not the case it is a serious bug.
On the other hand, if you implement method specific inspection in
checkFile(), then you essentially kill this optimization.
Please use this method carefully.

Eugene.


0
Comment actions Permalink

Okay, thanks for the response. I'll check again to make sure the behavior
is as I said and file a bug if necessary.

Is there a way to know whether IDEA plans to check the whole file method
by method? Does IDEA know this at the time? If it's possible, I'll file a
request for it, it will improve performance for my plugin a great deal, I
think.

"Keith Lea" <keith@cs.oswego.edu> wrote in message
news:301658632511230333008304@news.jetbrains.com...

>> At first I assumed using checkMethod and so on would give performance
>>

improvements

>> because only methods whose semantics may have changed would be
>>

re-inspected.

>> However, it appears that my inspection is being run on each method in
>> the class, no matter how small the change is.
>>

No, this should not happen. When you type e.g. in method body, only
the
method itself should be rechecked.
If this is not the case it is a serious bug.
On the other hand, if you implement method specific inspection in
checkFile(), then you essentially kill this optimization.
Please use this method carefully.
Eugene.




0

Please sign in to leave a comment.