Highlighting the class name instead of the entire class should be pretty easy. I think a tiny change to your ClassHasNotStringMethodInspection should be enough. In the line:
ProblemDescriptor problem = im.createProblemDescriptor(clazz, "Class does not overwrite toString() method", fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
replace "clazz" by "clazz.getNameIdentifier()" and the inspection will highlight the name of the class. Note that I have not tested this, but I'm pretty sure it will work.
Bas
Claus Ibsen wrote:
It's one of the 3 hightlight types you have for inspections at that time.
I read somewhere that JetBrains would add more types in the EAP builds.
I haven't checked if they got such a highlight for just the class name.
I also got a few bugs to sort for the new builds. But I'm without internet at home so it could take a while before a new version is released.
It's one of the 3 hightlight types you have for inspections at that time.
I read somewhere that JetBrains would add more types in the EAP builds.
I haven't checked if they got such a highlight for just the class name.
I also got a few bugs to sort for the new builds. But I'm without internet at home so it could take a while before a new version is released.
Highlighting the class name instead of the entire class should be pretty
easy. I think a tiny change to your ClassHasNotStringMethodInspection
should be enough. In the line:
ProblemDescriptor problem = im.createProblemDescriptor(clazz, "Class
does not overwrite toString() method", fix,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
replace "clazz" by "clazz.getNameIdentifier()" and the inspection will
highlight the name of the class. Note that I have not tested this, but
I'm pretty sure it will work.
Bas
Claus Ibsen wrote:
Thanks Bas I'll try it this weekend and let you know how it went.
Make sure to test the identifier for null, or you'll NPE on anonymous inner classes (which have no name identifier).
--Dave Griffith
I just released v3.16 that has this fixed.
Hi Bas
It worked like a charm. However anonymous classes isn't inspected as I skip all classes that doesn't have a name. So the null check is not needed.
I can't see a use case where a toString() is needed for anonymous classes.