Bug 22381 - Show unused fields and variables [refactoring] [search]
Summary: Show unused fields and variables [refactoring] [search]
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-13 09:21 EDT by Paolo CLA
Modified: 2003-02-11 07:16 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo CLA 2002-08-13 09:21:29 EDT
Show (other color or italic or undelined ) when we have fileds and varibles 
that are not used in the class.

Also an command "Cleanup fields and variables" would be fine...As example have 
a look at Intellij IDEA...

-pavel
Comment 1 Dirk Baeumer CLA 2002-08-13 11:22:55 EDT
The functionality exists for unused locals and parameters. To enable it do the 
following:

- Preferences->Java->Compiler->Errors and Warnings: set Unused to error or 
warning
- Preferences->Java->Editor->Problem Indication->Show Problems before compiling

You now get a light bulb for unused locals and paramters. You can fix those by 
clicking on the light bulb and selecting the "Remove ...." quick fix.

Fields are a little bit more complicated since the can be referenced by more 
than one CU. The idea here is that we provide special search that search for 
unused fields and methods. You can then remove the fields by selecting an 
action from the search results context menu.
Comment 2 Paolo CLA 2002-08-14 04:09:53 EDT
hi dirk

silly silly me! thanks a lot for your kind reply with the explanation! I 
thought I can handle the eclipse help: searched for "unused fields" but did not 
find anything obviously related to my request. Should have searched for "unused 
variables" instead...

Sorry and thanks for your time!

-pavel

Comment 3 Dani Megert CLA 2002-08-15 08:40:47 EDT
Moving to core - two issues/requests here:
1) The compiler could produce warnings/errors for unused PRIVATE stuff and this
could be resolved by the user via quick fix
2) The search engine should be extened so that we can offer such a search from
the UI.
Comment 4 Philipe Mulet CLA 2002-09-23 04:53:40 EDT
1- unused private members could be detected, but they may still be used outside 
incorrectly (removing them would change error messages in dependents - likely 
ok).

2- no need for a search engine extension to do so, just look for appropriate 
markers.
Comment 5 Philipe Mulet CLA 2003-01-21 06:07:38 EST
Support added:

New compiler problems got added to report declarations of unused private 
members (field/method/type). A JavaCore setting
got added to control the severity of these new problems (default severity is 
IGNORE). Note that currently only a valid local usage 
is considered as a true usage (e.g. if a message send targets this method, but 
cannot see it, then the target method will still be 
reported as unused). Corresponding problem IDs are: 
<code>IProblem.UnusedPrivateMethod</code>, 
<code>IProblem.UnusedPrivateField</code>, 
<code>IProblem.UnusedPrivateType</code>.
<pre>
* COMPILER / Reporting Unused Private Members
*    When enabled, the compiler will issue an error or a warning whenever a 
private 
*    method or field is declared but never used within the same unit.
*     - option 
id:         "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
*     - possible values:   { "error", "warning", "ignore" }
*     - default:           "ignore"
</pre>
Comment 6 David Audel CLA 2003-02-11 07:16:46 EST
Verified.