Skip to main content

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

Hi,

 

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"?>

<templates>

               

                <template name="sas_c_file_comment" id="com.sas.tools.cdt.ui.text.codetemplates.cFileComment" 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:   

 *  LANGUAGE:   C

*  SCRIPT:    

 *  PURPOSE:   

 *

*  HISTORY:

*    Defect    Action                        Date        Name

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

*   

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

*/

                </template>

                <template name="SAS C Source File" id="com.sas.tools.cdt.ui.text.codetemplates.csourcefile" description="Default SAS C Source Template" context="org.eclipse.cdt.core.cSource.contenttype_context" enabled="true">             

                   ${sas_c_file_comment}

 

       ${includes}

 

       ${declarations}

    </template>

               

 

</templates>

 

 

Thanks,

Joseph.


Back to the top