Bug 58262 NPE after showing empty refactoring menu
build i0407-1337, winxp, sun jdk 1.4.2_03 I got the following NPE in my console. Here are the steps that I did: - opened revision of code to look at (InternalPlatform 1.86) - no outline so I tried ctrl-o (didn't work...didn't expect either to work) - right clicked and saw 2 menu options...Copy and Refactoring - expanded the Refactoring menu and it said something like <no refactorings available> - left-clicked on the editor to get rid of the menu and place focus back on the editor - got the NPE !ENTRY org.eclipse.ui 4 4 Apr 13, 2004 09:08:47.311 !MESSAGE Unhandled event loop exception Unhandled event loop exception Reason: !ENTRY org.eclipse.ui 4 0 Apr 13, 2004 09:08:47.321 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActions.co nvertToEnclosingOrPrimaryType(RefactoringActions.java:50) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActions.ge tEnclosingOrPrimaryType(RefactoringActions.java:40) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.canEnable(ExtractIn terfaceAction.java:144) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.selectionChanged(Ex tractInterfaceAction.java:137) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionC hanged(SelectionDispatchAction.java:202) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.update(SelectionDi spatchAction.java:114) at org.eclipse.jdt.ui.actions.RefactorActionGroup.refactorMenuShown(Refa ctorActionGroup.java:501) at org.eclipse.jdt.ui.actions.RefactorActionGroup.access$1(RefactorActio nGroup.java:486) at org.eclipse.jdt.ui.actions.RefactorActionGroup$1.menuAboutToShow(Refa ctorActionGroup.java:441) at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java :286) at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.ja va:370) at org.eclipse.jface.action.MenuManager.access$0(MenuManager.java:367) at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:383 ) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java: 116) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:769) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:793) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:774) at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:3295) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2967) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1446) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3155) at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method) at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:222) at org.eclipse.swt.widgets.Display.runPopups(Display.java:2613) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2258) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1561) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1532) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.jav a:257) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90 ) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformAct ivator.java:279) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:241) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:267) at org.eclipse.core.launcher.Main.run(Main.java:692) at org.eclipse.core.launcher.Main.main(Main.java:676) java.lang.NullPointerException
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/RefactorActionGroup.java
fUseSupertypeAction= new UseSupertypeAction(fSite);
		fUseSupertypeAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.USE_SUPERTYPE);
		initAction(fUseSupertypeAction, provider, selection);
		
		fInlineAction= new InlineAction(fSite);
		fInlineAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.INLINE);
		initAction(fInlineAction, provider, selection);
		
		fIntroduceFactoryAction= new IntroduceFactoryAction(fSite);
		fIntroduceFactoryAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.INTRODUCE_FACTORY);
		initAction(fIntroduceFactoryAction, provider, selection);
		
		fConvertAnonymousToNestedAction= new ConvertAnonymousToNestedAction(fSite);
		fConvertAnonymousToNestedAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONVERT_ANONYMOUS_TO_NESTED);
		initAction(fConvertAnonymousToNestedAction, provider, selection);
		
		fKeyBindingService= keyBindingService;
		if (fKeyBindingService != null) {
			fQuickAccessAction= new RefactorQuickAccessAction(null);
			fKeyBindingService.registerAction(fQuickAccessAction);
		}
	}
	
	private static void initAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection){
		action.update(selection);
		provider.addSelectionChangedListener(action);
	}
	
	/* (non-Javadoc)
	 * Method declared in ActionGroup