Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315365

Summary: [templates] ClassCastException when using ${todo} in file template
Product: [Tools] CDT Reporter: Anton Leherbauer <aleherb+eclipse>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: 7.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fix aleherb+eclipse: iplog-

Description Anton Leherbauer CLA 2010-06-02 05:50:10 EDT
When creating a file from a template which contains ${todo} an exception is logged and the wizard does not complete:

java.lang.ClassCastException: org.eclipse.cdt.internal.corext.template.c.FileTemplateContext cannot be cast to org.eclipse.cdt.internal.corext.template.c.CodeTemplateContext
at org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType$Todo.resolve(CodeTemplateContextType.java:102)
at org.eclipse.jface.text.templates.TemplateVariableResolver.resolveAll(TemplateVariableResolver.java:98)
at org.eclipse.jface.text.templates.TemplateVariableResolver.resolve(TemplateVariableResolver.java:114)
at org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType.resolve(FileTemplateContextType.java:218)
at org.eclipse.jface.text.templates.TemplateContextType.resolve(TemplateContextType.java:240)
at org.eclipse.cdt.internal.corext.template.c.FileTemplateContext.evaluate(FileTemplateContext.java:67)
at org.eclipse.cdt.internal.corext.codemanipulation.StubUtility.evaluateTemplate(StubUtility.java:379)
at org.eclipse.cdt.internal.corext.codemanipulation.StubUtility.getFileContent(StubUtility.java:141)
at org.eclipse.cdt.internal.ui.wizards.filewizard.WizardNewFileFromTemplateCreationPage.getInitialContents(WizardNewFileFromTemplateCreationPage.java:146)
at org.eclipse.ui.dialogs.WizardNewFileCreationPage.createNewFile(WizardNewFileCreationPage.java:380)
at org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileFromTemplateWizard.performFinish(NewFileFromTemplateWizard.java:84)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:811)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:430)
[...]
Comment 1 Anton Leherbauer CLA 2010-06-02 10:15:51 EDT
Created attachment 170803 [details]
Fix
Comment 2 Anton Leherbauer CLA 2010-06-02 10:16:48 EDT
The fix is safe.  Committed to HEAD.