I’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.
I’m not good Java2D programmer, can you explain me why IDEA highlighted that piece of code? Thanks! 🙂
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.
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 🙂
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.
I like how they get the old pelope who buy anything on midnight info commercials to endorse it on live TV
1XCu2i zchjmuemgbba