Bug 71968 - [options] Would like to have pragmas to disable warnings for individual files
Summary: [options] Would like to have pragmas to disable warnings for individual files
Status: RESOLVED DUPLICATE of bug 83739
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-13 15:41 EDT by Rustam CLA
Modified: 2005-04-07 09:46 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rustam CLA 2004-08-13 15:41:30 EDT
Some java files are generated (such as JLex files) and have many unused (i.e. 
never read) attributes. I would like to be able to disable these warnings on a 
file-by-file basis by using some special comments (pragmas) in those files.

For example:
/**
 * @@(pragma) warn -unused_attributes
 */
Comment 1 Michael Moser CLA 2004-12-06 11:15:56 EST
It should also be possible to just "locally" suppress warnings, i.e. not only 
on a file basis but just for specific occurences (or between special "brackets" 
or comments).

E.g. I vey much appreciate the "field is never read" warning. Alas, our legals 
require us to have a COPYRIGHT = "..." string in EACH class. This string is of 
course never used and thus yields said warning. We normally declare these 
strings private since otherwise, e.g. when declaring them protected or public, 
when deriving from such a class, it causes another warning "foo.COPYRIGHT is 
hiding a field from bar".

Since I have to keep the offending code as-is in my source code this causes ALL 
my files to be flag with a warning sign as well as generating tons of 
annoying "Problems" that I need to wade through to find signigficant entries.

So, IMHO, the best solution would be, if the compiler could be told to just 
locally suppress that warning.
Comment 2 Philipe Mulet CLA 2004-12-06 15:56:08 EST
1.5 language is offering an annotation for this: @SuppressWarnings (which can
take arguments for specific warnings).
Comment 3 Steven Buroff CLA 2004-12-07 09:43:10 EST
I think that supporting the @SupportWarnings annotation is the best solution
but the ability to suppress warnings on a per statment basis is necessary. 
Just the ability to suppress all warnings in a file is not really good enough.
Comment 4 Philipe Mulet CLA 2004-12-07 09:54:04 EST
Not disagreeing, but then the code would be polluted by meta comments,
recognized by the compiler, like for // $NON-NLS1$   in existing code.
Imagine how your code would look like with 50 different such tags...

Also, agreeing on warning names across compiler vendors isn't something on the
radar, so anything we would add would be very specific to our compiler
implementation. This is why we have been reluctant to provide custom support.
There is JSR(199) on compiler APIs which could provide some enhancements on this
front.
Comment 5 Steven Buroff CLA 2004-12-07 10:00:16 EST
I don't understand your comment Phillippe. If you supported @SuppressWarnings,
that wouldn't be specific to the eclipse compiler, right? Its part of Java 1.5.
Comment 6 Philipe Mulet CLA 2005-04-07 09:46:48 EDT

*** This bug has been marked as a duplicate of 83739 ***