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
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.ui.fix;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;