#382 WhitespaceAroundCheck and Generics

release_4.0
closed
5
2012-10-10
2005-10-19
No

Missing Whitespace around < (LT) and > (GT) should
not be reported if these tokens are used for generics.

I.e. it should be allowed to write
Map (instead of Map < String, String > )
while this check should still be able to tell about the
missing whitespace in
if (x>5 && x<10)

My current workaround is to turn the check off for these
two tokens for Java 5 code, but I consider this not
acceptable in the long run.

I consider this is a bug and not a RFE:
WhitespaceAroundCheck is not a primitive check as it
knows about the grammar, e.g. it knows that it's OK for
the colon after "case" to lack whitespace before it, and it
knows about the special meaning of the star in "import
pkg.name.*;", etc.
So it should know about the grammar details regarding
generics, too.

(This applies to 4.0.0 beta 6)

Discussion

  • Logged In: YES
    user_id=1227261

    Sorry, I wrote the bug report a little bit too soon:

    Turning off LT and GT does not work. Instead, there are
    already tokens named GENERIC_START and
    GENERIC_END, and turning them off works as expected.

    I leave this bug report open as the documentation should be
    updated regarding this issue, e.g. a new chapter regarding
    Java 5, some hints which explain the tokens, and cross
    references between the javadoc of LT-GENERIC_START and
    GT-GENERIC_END etc.

    Generally, it is not a good idea that actual token names have
    to be put in the config files.

     
  • Logged In: YES
    user_id=1238882


    The eclipse-cs plugin configuration editor is capable of
    translating checkstyle tokes into a more eye friendly form.
    For instance GT is translated as 'greater than operator (>)'
    and GENERIC_END as 'End of generic type arguments (>)'.

    I think this makes it easier to distinguish the tokens.
    Maybe this eases your pain with tokens in the configuration
    fiel a bit?

    Regards,
    Lars Kdderitzsch

     
  • Logged In: YES
    user_id=1227261

    Hi Lars, I would like to continue this discussion at eclipse-cs.
    Please see RFE 1333015.

    I am actually using eclipse-cs, and am aware of that feature
    of it, but it didn't really help me.

     
  • Logged In: YES
    user_id=746148

    I think this is a duplicate of 1255367 (WhitespaceAround
    documentation needs updating)
    So, closing this one as duplicate.