Bug 112440 Generate Delegate Methods does not work in anonymous types
Build ID: I20051011-1655 When selecting "Generate Delegate Methods" for an anonymous type, the refactoring does not use the fields of the anonymous type, but of the enclosing type as a reference (1). When inserting methods (from fields of the enclosing type) at the current position, it fails without an error message (2). 1) Select "Foo()", invoke the Refactoring => No generation possible 2) Add a field to top-level class Foo, select "Foo()" invoke the Refactoring, select some method and "insert at current position" => Generation possible, but methods do not get inserted. ---- public class Foo { public void foo() { Foo d= new Foo() { Foo d; }; } } ----
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddDelegateMethodsAction.java
/*
	 * (non-Javadoc) Method declared on SelectionDispatchAction
	 */
	public void selectionChanged(IStructuredSelection selection) {
		try {
			setEnabled(canEnable(selection));
		} catch (JavaModelException e) {
			
			if (JavaModelUtil.isExceptionToBeLogged(e))
				JavaPlugin.log(e);
			setEnabled(false);
		}
	}
	
	/*
	 * (non-Javadoc) Method declared on SelectionDispatchAction
	 */
	public void selectionChanged(ITextSelection selection) {
	}
	private void showUI(IType type, IField[] fields) {
		try {
			AddDelegateMethodsContentProvider provider= new AddDelegateMethodsContentProvider(type, fields);
			SourceActionDialog dialog= new AddDelegateMethodsDialog(getShell(), new AddDelegateMethodsLabelProvider(), provider, fEditor, type, false);
			dialog.setValidator(new AddDelegateMethodsActionStatusValidator(provider.getCount()));
			AddDelegateMethodsViewerSorter sorter= new AddDelegateMethodsViewerSorter();
			dialog.setSorter(sorter);
			dialog.setInput(new Object());
			dialog.setContainerMode(true);
			dialog.setMessage(ActionMessages.AddDelegateMethodsAction_message); 
			dialog.setTitle(ActionMessages.AddDelegateMethodsAction_title);