I Love Intelligent Tools…
Technology January 18th, 2007I’m writing some Java2D code, and I notice that IDEA (my code editor) highlighted parts of my code:

Check out the caption at the bottom of the window. It turns out (as any good Java2D programmer knows) I’m reversing the width and height arguments — but how did IDEA know? Whether its lexical analysis or a special case built into the tool, wow! This kind of stuff is infinitely useful.

January 18th, 2007 at 9:29 am
I’m not good Java2D programmer, can you explain me why IDEA highlighted that piece of code? Thanks!
January 18th, 2007 at 10:17 am
jz: The order is reversed; methods that take height and width arguments take the width first, and then the height (just as x logically precedes y). Admittedly, IDEA’s error could have been clearer, like “It looks like you reversed the width and the height” instead of the message shown.
January 19th, 2007 at 2:44 am
Hi Ben,
thank you for explanation (I bad translated word reversing), now I understand. One tip: If IDEA doesn’t analyse this by lexical way, try set width by lesser value than height one
March 9th, 2007 at 12:44 am
It’s a feature of the inspection gadgets plugin which is bundled with IDEA. You can even add more name patterns for similar things, just check you inspection configuration.
April 2nd, 2007 at 12:08 am
el lady mature…
Technologies of el lady mature…
April 20th, 2007 at 10:29 am
[…] Notice in the overly-small screen-shot above that I’m passing a constant containing the word “HEIGHT” into a method that’s expecting a unit value along the X axis. I have no idea what algorithm IDEA employs to figure out that I’m passing a Y axis value to a method expecting an X axis value, but I say again, wow. […]