Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 215161
Collapse All | Expand All

(-)ui/org/eclipse/jdt/ui/actions/GenerateNewConstructorUsingFieldsAction.java (-4 / +16 lines)
Lines 13-18 Link Here
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.Arrays;
16
import java.util.HashMap;
16
import java.util.List;
17
import java.util.List;
17
18
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
Lines 321-327 Link Here
321
			return;
322
			return;
322
		}
323
		}
323
324
324
		ArrayList fields= new ArrayList();
325
		HashMap fieldsToBindings= new HashMap();
325
		ArrayList selected= new ArrayList();
326
		ArrayList selected= new ArrayList();
326
327
327
		IVariableBinding[] candidates= typeBinding.getDeclaredFields();
328
		IVariableBinding[] candidates= typeBinding.getDeclaredFields();
Lines 339-354 Link Here
339
					continue; // Do not add final fields which have been set in the <clinit>
340
					continue; // Do not add final fields which have been set in the <clinit>
340
				}
341
				}
341
			}
342
			}
342
			fields.add(curr);
343
			IJavaElement javaElement= curr.getJavaElement();
343
			if (allSelected.contains(curr.getJavaElement())) {
344
			fieldsToBindings.put(javaElement, curr);
345
			if (allSelected.contains(javaElement)) {
344
				selected.add(curr);
346
				selected.add(curr);
345
			}
347
			}
346
		}
348
		}
347
		if (fields.isEmpty()) {
349
		if (fieldsToBindings.isEmpty()) {
348
			MessageDialog.openInformation(getShell(), ActionMessages.GenerateConstructorUsingFieldsAction_error_title, ActionMessages.GenerateConstructorUsingFieldsAction_typeContainsNoFields_message);
350
			MessageDialog.openInformation(getShell(), ActionMessages.GenerateConstructorUsingFieldsAction_error_title, ActionMessages.GenerateConstructorUsingFieldsAction_typeContainsNoFields_message);
349
			notifyResult(false);
351
			notifyResult(false);
350
			return;
352
			return;
351
		}
353
		}
354
		
355
		ArrayList fields= new ArrayList();
356
		IField[] allFields= type.getFields();
357
		for (int i= 0; i < allFields.length; i++) {
358
			Object fieldBinding= fieldsToBindings.remove(allFields[i]);
359
			if (fieldBinding != null) {
360
				fields.add(fieldBinding);
361
			}
362
		}
363
		fields.addAll(fieldsToBindings.values()); // paranoia code, should not happen
352
364
353
		final GenerateConstructorUsingFieldsContentProvider provider= new GenerateConstructorUsingFieldsContentProvider(fields, selected);
365
		final GenerateConstructorUsingFieldsContentProvider provider= new GenerateConstructorUsingFieldsContentProvider(fields, selected);
354
		IMethodBinding[] bindings= null;
366
		IMethodBinding[] bindings= null;

Return to bug 215161