Project: JDT
Bug 151062 [templates] 'for' template does not work in detail formatters dialog
Reported: 2006-07-19 06:50:59 | Status: resolved fixed

I20060718-0800 Preferences > Java > Debug > Detail Formatters: Add a detail formatter, write "for", invoke content assist, and chose any of the for templates. -> Template not inserted, log: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.template.java.JavaContext.suggestVariableName(JavaContext.java:393) at org.eclipse.jdt.internal.corext.template.java.JavaContext.suggestVariableNames(JavaContext.java:377) at org.eclipse.jdt.internal.corext.template.java.NameResolver.resolve(NameResolver.java:75) at org.eclipse.jface.text.templates.TemplateContextType.resolve(TemplateContextType.java:272) at org.eclipse.jface.text.templates.TemplateContextType.resolve(TemplateContextType.java:239) at org.eclipse.jdt.internal.corext.template.java.JavaContext.evaluate(JavaContext.java:164) at org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal.apply(TemplateProposal.java:173) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:784) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:735) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1142) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:761) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:436) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:61) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:709) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5051) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4793) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3349) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3249) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4054) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1927) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2995) at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) at org.eclipse.jface.window.Window.open(Window.java:796) at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersPreferencePage.editType(JavaDetailFormattersPreferencePage.java:324) at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersPreferencePage$4.doubleClick(JavaDetailFormattersPreferencePage.java:181) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:796) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:843) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:794) at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:1051) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1158) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:223) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:220) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:281) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3377) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2997) at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) at org.eclipse.jface.window.Window.open(Window.java:796) at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:65) at org.eclipse.jface.action.Action.runWithEvent(Action.java:499) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3377) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2997) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) at org.eclipse.core.launcher.Main.basicRun(Main.java:280) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContext.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaFormatter.java