Bug 318608 - Future request. Warnings if we do not use a public method
Summary: Future request. Warnings if we do not use a public method
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-01 10:27 EDT by Lars Svensson CLA
Modified: 2010-08-03 09:41 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Svensson CLA 2010-07-01 10:27:46 EDT
Build Identifier: 

I like tidying up my code and use settings like "Unused local or private member". This works great. But why isn't there a similar setting to warn for not used PUBLIC methods and fields??

Reproducible: Always
Comment 1 Srikanth Sankaran CLA 2010-07-02 00:43:28 EDT
The idea behind the warning is that you should be able to
get rid of the complained against item, say by using a
quick fix offered by the IDE, or otherwise by manually.

Given public methods are exposed to the whole wide world,
there could be parts of the code not seen by the compiler
that use the method. This will trigger the warning for most
API methods, where there is no usage "locally" - i.e, the
client code that uses these methods is compiled independently.

See that in cases like what is shown below, the compiler
does produce a warning as appropriate: because the region
of code where such a public method is usable is well bounded
by the language specification, the compiler can and does
verify usage:

public class Tools {    
    private class Private {
    	public void foo() {
    		
    	}
    }
    Private p = new Private();
}

For more general cases, I doubt that anything could be done that
would not also open the flood gates for numerous other pointless
or just plain incorrect warnings.
Comment 2 Olivier Thomann CLA 2010-07-02 10:09:37 EDT
As Srikanth explained, there is nothing we can do for public methods.
Closing as INVALID.
Comment 3 Ayushman Jain CLA 2010-08-03 09:41:08 EDT
Verified for 3.7M1