How do I suppress Eclipse 3.5's warnings of dead code

前端 未结 3 991
难免孤独
难免孤独 2021-02-07 09:44

I use a class for detecting email addresses which uses static final booleans to configure the matching behavior. Since I upgraded to Eclipse 3.5 I get warnings about dead code,

3条回答
  •  执笔经年
    2021-02-07 10:31

    UPDATE: from Adam's comment:

    In Eclipse 3.6 and newer Eclipse versions @SuppressWarnings("unused") can now be used to suppress 'dead code' warnings. See Christopher Stock's answer.

    See also Eclipse 4.4(Luna) help for @SuppressWarnings.

    Original answer:

    All SuppressWarnings values Eclipse 3.5 "knows" are listed in this page. It seems that there is no value for suppressing only the new dead-code detection. But you can use the @SuppressWarnings("all") just before the domain declaration so it will suppress warnings for only that line not for the whole class:

    private static final boolean ALLOW_DOMAIN_LITERALS = false;
    @SuppressWarnings("all") 
    private static final String domain = ALLOW_DOMAIN_LITERALS ? rfc2822Domain : rfc1035DomainName;
    

    Because dead code check is a new one you can also suggest an enchancement in the Eclipse bug database for supporting the ternary operation as well.

提交回复
热议问题