Hi!

One of the features with IntelliJ that I like best is that the editor shows
you where you have syntax errors (red) and where you have "unneccessary"
code (yellow).
I always endeavor to get the error-marker "green" for all source files.

However, there are cases where this is not possible, because IntelliJ
"warns" me (with yellow) about stuff it simply does not understand well
enough.

Example: If in a Serializable object I want to override one of the "special"
methods "writeObject" or "readObject", I *have* to use this exact
signatures:

private void writeObject(ObjectOutputStream out) throws IOException
and
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException

And usually you would never call these methods yourself, but let the "magic"
behind "Serializable" call them. So IntelliJ marks these method with
"yellow" and gives the message "method writeObject never called" (or
similar).
Similarly, if I implement the body of the method in a way that it can never
throw one of the declared exceptions (IO or ClassNotFound), then IntelliJ
also marks those exceptions as never thrown in the body.
Of course, compiliation and everything works fine, but I have to live with
the "yellow" warnings, and can never get that source file to "green" :-(

Suggestion: Make a special case out of these two methods and the similar
"writeReplace" and "readResolve" methods (see Serializable description), so
that "never called" is not a warning-condition for them.

Anyway, the same problem also appears if I have private methods that I do
never call from the code directly, but that I do call via reflection.
I know, it does sound weird to say that I have a private method, which I
never call from the class' code directly, but which I call via reflection
anyway, but believe me, we have a very usuful implementation using this,
where a base class contains some generic methods, which are able to access
the getter and setter methods from the actual inherited classes via
reflection. And since we want to make sure that we do not call our setter
methods directly, but only via the "generic" methods in the base class, we
simply make the setter methods private - which in IntelliJ has the effect
that they are marked "yellow" with the warning "never called".

So if I had a wish, I would ask for an option where you could specify if the
editor should warn about private methods that are "never called" or not,
and - when thinking this to the end - a second option for private fields too
(since those could be accessed via reflection too).

Johannes



_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-features

Reply via email to