Bug 114369 Remove unused local and field too dangerous for multi quick fix
Version: 3.1.0 Build id: I20051025-0800 The two clean ups: Remove unused local variable and assignments without possible side effects and Remove unused private field and assignments without possible side effects are too dangerous to apply in a batch mode, at least without warning the user. Reason: private int i= methodWithSideEffect(); foo () { int j= methodWithSideEffect(); } in both cases i and j are removed as well as the two calls to methodWithSideEffect which will change the semantic of the program. Possible solutions: 1. Not having these two multi quick fixes 2. Warn the user 3. Only remove variables if this does not remove any method call 4. ?
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnusedCodeMultiFix.java
public Map getRequiredOptions() {
		Map options= new Hashtable();
		if (fRemoveUnusedImports) {
			options.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.WARNING);
		}
		if (fRemoveUnusedPrivateMethods || fRemoveUnusedPrivateConstructors || fRemoveUnusedPrivateFields || fRemoveUnusedPrivateTypes) {
			options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.WARNING);
		}
		if (fRemoveUnusedLocalVariables) {
			options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.WARNING);
		}
		return options;
	}
	public Control createConfigurationControl(Composite parent) {
		Composite composite= new Composite(parent, SWT.NONE);
		composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));
		composite.setLayout(new GridLayout(1, true));
		
		Button removeUnusedImport= new Button(composite, SWT.CHECK);
		removeUnusedImport.setText(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedImport_description);
		removeUnusedImport.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
		removeUnusedImport.setSelection(fRemoveUnusedImports);
		removeUnusedImport.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				fRemoveUnusedImports= ((Button)e.getSource()).getSelection();
			}
		});
		
		Button removePrivateMethods= new Button(composite, SWT.CHECK);
		removePrivateMethods.setText(MultiFixMessages.UnusedCodeMultiFix_RemoveUnusedMethod_description);