Summary: | Show unused fields and variables [refactoring] [search] | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Paolo <pavel4u> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | ||
Version: | 2.0 | ||
Target Milestone: | 2.1 M5 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Paolo
2002-08-13 09:21:29 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. 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 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. 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. 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> Verified. |