Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Extending Code Templates

Ok, so I am still not able to get this working.


Is there someone on this list that could explain to me how to properly use this extension (org.eclipse.ui.editors.templates)?


Basically my short term goal is this:


1.)    Contribute a template that will when “New -> Source File” is chosen, I can choose my custom template for the source code

2.)    Allow that custom template to be able to use variable that I have defined


Any help would be appreciated.



Joseph Henry.


From: Joseph Henry
Sent: Wednesday, October 23, 2013 10:05 AM
To: 'CDT General developers list.'
Subject: RE: Extending Code Templates


I think I figured it out. I am pretty sure that I needed a resolver component.


Sorry for jumping the gun on posting.


From: Joseph Henry
Sent: Wednesday, October 23, 2013 9:54 AM
To: CDT General developers list.
Subject: Extending Code Templates




I am in need to distributing some default code templates with our plugin and am having a hard time getting this to work.


I have created an extension in my plugin org.eclipse.ui.editors.templates and created an include child.


For the simple case I want to create a C Source code template similar to org.eclipse.cdt.ui.text.codetemplates.csourcefile But I want it to use our companies default comment header.


I used the file /org.eclipse.cdt.ui/templates/default-codetemplates.xml as an example and was able to create a template using the default variables, but when I tried to create a new variable, it would not work.


How I attempted to create a variable was to define a section in the xml with the variable name, and define its content. I am guessing that is not the right way because it does not work.


I guess my question is: How do you create a substitution variable for a code template? My xml is pasted below.



<?xml version="1.0" encoding="UTF-8"?>



                <template name="sas_c_file_comment" id="" context="org.eclipse.cdt.ui.text.codetemplates.filecomment_context" enabled="true"

                                description="Default comments for a SAS C Source File">


*  Copyright (C), ${year}

*  SAS Institute Inc., Cary, N.C. 27513, U.S.A.  All rights reserved.

* --------------------------------------------------------------------


*  NAME:       {file_name}

*  AUTHOR:     {user}

*  DATE:       {date}

*  SUPPORT:    {user} -

 *  PRODUCT:   


*  SCRIPT:    

 *  PURPOSE:   



*    Defect    Action                        Date        Name

*    ----------------------------------------------------------------


 *    ----------------------------------------------------------------



                <template name="SAS C Source File" id="" description="Default SAS C Source Template" context="org.eclipse.cdt.core.cSource.contenttype_context" enabled="true">             














Back to the top