3512 Intention / Inspection quickfix hocus pocus

I have been running into a wierd behavior with the ALT+Enter intention menu. I don't think it is a new issue in 3512, because I have seen it before during EAP.

Sometimes, if I use keyboard to navigate to a symbol on a line, and hit ALT+ENTER, an intention I expect to be there doesn't show up.

If I then move the cursor over the symbol to get the warning tooltip, and then hit ALT+ENTER, then the missing Intention appears.

Here is an example. (See pictures)

1. I use keyboard to put caret inside the "toString()" method call. I hit ALT+ENTER. I see th intentions:

Remove braces from if statement
Replace + with .append().

2. I think mouse over the "toString()" method to get
the warning tooltip.

3. I then hit ALT+ENTER again and now I get:

Remove .toString()
Remove braces from if statement
Replace + with .append().

Once the "Remove .toString()" shows up, it always shows up after that.
I have seen this in several other cases also. I will post other examples if I hit them again.
Anybody else see this wierd behavior?



Attachment(s):
3512_missing_intention_Remove_toString.gif
3512_tooltip_Calls_to_StringBuffer_toString.gif
3512_Remove_toString_now_appears.gif
7 comments

One other wierd thing is that the "Remove braces from if statement" is totally bogus. The caret is inside the "toString()" method of "url.toString()". There are no braces in the statement on that line.

I tried hitting ALT+ENTER on some other lines which have variable declarations, and the "Remove braces from if statement" is popping up on every line!

Maybe this has something do to with the fact I disabled the "Remove braces form if statement" in Intention Settings. Could be a bug when you disable intentions?

0

In my experience intentions usually show up in two phases while IDEA is analyzing. First IDEA analyzes the syntax, then the regular intentions show up. This is usually pretty fast.

After that the quick fixes for the inspections enabled for on-the-fly highlighting appear. This can sometimes take a while, for example if many inspections are enabled. It also happens that the highlighting from a previous analysis run is still present, while IDEA is processing the current analysis run. Then the highlighting is present, but the quick fixes still need to show up.

Maybe that could explain the behaviour that you are seeing? Or do you see it too if IDEA is completely finished analyzing the current editor?

Bas

0

The "Remove braces from if statement" is indeed a bit trigger happy. Maybe you could sumbit a JIRA report about it? It would be great if it could contain some examples or explanation of where you would expect the intention and where you would definately not expect it.

Bas

0

I agree about the two-stage syntax/intention processing. This can be a real pain. Sometimes I think I'd rather have the quick-fix inspections run only on demand (i.e. manually) rather than take pot luck that inspection processing has finished when I get to the next warning. Often you have to wait a fair while before you get the 'quick-fix' intention you know should be there, which is frustrating and kind of defeats the point of on-the-fly quick-fixes.

The problem seems to arise because all the intentions must be run after every code change, which means they will always struggle to keep up if you run through existing code with F2 to fix multiple warnings.

0

The easiest way to fix multiple warnings is usually "Inspect Code With Editor Settings (ShiftAltI)". The quick fixes (even multiple at once) can then be invoked from the inspection results panel without the wait for a new analysis.

Bas

0

OK - thanks, I'll give that a try.

0

Please sign in to leave a comment.