diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java index dfaa8b9e1e7..2cfed737828 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java @@ -52,6 +52,8 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog; import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; + /** * A dialog to select an element from a filterable list of elements. * @@ -161,6 +163,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { */ public ElementSelectionDialog(Shell parent) { super(parent); + setHelpContextId(ICHelpContextIds.OPEN_ELEMENT_DIALOG); setMatchEmptyString(false); fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name); fUpdateJob.setRule(SINGLE_INSTANCE_RULE); diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java index b6633f70a1c..2e27320dcde 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java @@ -501,10 +501,12 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { section.put(SETTINGS_X_POS, location.x); section.put(SETTINGS_Y_POS, location.y); - Point size = getShell().getSize(); - section.put(SETTINGS_WIDTH, size.x); - section.put(SETTINGS_HEIGHT, size.y); - + if (getTray() == null) { + // only save size if help tray is not shown + Point size = getShell().getSize(); + section.put(SETTINGS_WIDTH, size.x); + section.put(SETTINGS_HEIGHT, size.y); + } section.put(SETTINGS_SHOW_NAMESPACES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_NAMESPACE))); section.put(SETTINGS_SHOW_CLASSES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_CLASS))); section.put(SETTINGS_SHOW_STRUCTS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_STRUCT))); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java index 7cb4d43cf4b..219506e0d0e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java @@ -123,6 +123,7 @@ public interface ICHelpContextIds { // Dialogs public static final String EDIT_TEMPLATE_DIALOG = PREFIX + "edit_template_dialog_context"; //$NON-NLS-1$ + public static final String OPEN_ELEMENT_DIALOG = PREFIX + "open_element_dialog_context"; //$NON-NLS-1$ // view parts public static final String TYPE_HIERARCHY_VIEW= PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$ diff --git a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_comments.htm b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_comments.htm index 47d9fe847b9..2573ad2b11d 100644 --- a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_comments.htm +++ b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_comments.htm @@ -38,7 +38,7 @@ Type com+Ctrl+Space, and the following code is entered at the cursor lo * author userid * * To change this generated comment edit the template variable "comment": - * Window>Preferences>C>Templates. + * Window > Preferences > C/C++ > Editor > Templates. */ @@ -54,8 +54,7 @@ Type com+Ctrl+Space, and the following code is entered at the cursor lo Commenting out code

Related reference
-C/C++ editor, code templates and search -preferences

+C/C++ editor preferences

Red Hat Copyright Statement
diff --git a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_content_assist.htm b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_content_assist.htm index 1c70c3cacdc..2587fead256 100644 --- a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_content_assist.htm +++ b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_content_assist.htm @@ -41,23 +41,23 @@ You trigger the Code completion feature when you call Content Assist (such as wh

You can view the signature of each item on the list in a pop-up by pointing to it. You can then select an item in the list to insert it directly into your code.

-

Code templates

+

Templates

-

You can create and save code templates for frequently used sections of code, which will be inserted according to scope. The Content Assist feature also provides quick access to code +

You can create and save templates for frequently used sections of code, which will be inserted according to scope. The Content Assist feature also provides quick access to code templates.

When you enter a letter combination in the C/C++ editor, and type CTRL+SPACE (or right-click and click Content Assist), a -list of code elements and code templates that start with the letter combination that you typed is displayed.

+list of code elements and templates that start with the letter combination that you typed is displayed.

-

You can then select a code template from the list and it is inserted directly into your code.

+

You can then select a template from the list and it is inserted directly into your code.

C++ example showing Code Assist popup

-

For example, the code template do while statement contains the following code:

+

For example, the template do while statement contains the following code:

Code Template showing do-while example

-

When you select the do code template from the list, you insert the following code:

+

When you select the do template from the list, you insert the following code:

do {
 } while (condition);

@@ -83,8 +83,8 @@ main(int argc, char **argv) {

Related tasks
Using Content Assist
-Creating and editing code templates
-Importing and exporting code templates

+Creating and editing templates
+Importing and exporting templates

Related reference
C/C++ perspective icons

diff --git a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_templates.htm b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_templates.htm index 10d8606660a..f9467cce697 100644 --- a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_templates.htm +++ b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_templates.htm @@ -28,9 +28,9 @@ The templates that begin with that character appear. Double-click on a template

Related tasks -
Creating and editing code templates +
Creating and editing templates
Using templates -
Importing and exporting code templates +
Importing and exporting templates

Related reference diff --git a/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml b/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml index f5e8610ea76..58bf70dea7a 100644 --- a/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml +++ b/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml @@ -337,5 +337,14 @@ + + Click below to see help. + + + + Specify the templates used for code generation and new files. + + diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_code_templates_pref.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_code_templates_pref.htm new file mode 100644 index 00000000000..c5096ccca52 --- /dev/null +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_code_templates_pref.htm @@ -0,0 +1,327 @@ + + + + + + + Code templates + + + + + +

+ Code templates +

+

The + +Opens the Code Templates preference page +C/C++ > Code Style > Code Templates preference page +lets you configure the format of newly generated code stubs, comments and files.

+ +

The code templates page contains templates that are used by actions that generate code and/or source files. +E.g. the New Class wizard uses source and header file templates to create new files and code templates to insert generated method stubs. +Templates contain variables that are substituted when the template is applied. Some variables are available in all templates, some are specific to templates.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Action

+
+

Description

+
+

New...

+
+

Opens the Code Template dialog to create a new file template.

+
+

Edit...

+
+

Opens the Code Template dialog to edit the currently selected code template.

+
+

Remove

+
+

Removes a user added file template. Predefined templates cannot be removed.

+
+

Import...

+
+

Imports templates from the file system.

+
+

Export...

+
+

Exports all selected templates to the file system.

+
+

Export All...

+
+

Exports all templates to the file system.

+
+ + +

Comment Templates

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Template Name

+
+

Specifies

+
+

Files

+
+

Header comment for new source or header files.

+

Note that this template can be referenced in source and header file templates with ${filecomment}.

+
+

Types

+
+

The comment for new types.

+

Note that this template can be referenced in source and header file templates with ${typecomment}.

+
+

Fields

+
+

The comment for new fields.

+
+

Constructors

+
+

The comment for new constructors.

+
+

Destructors

+
+

The comment for new destructors.

+
+

Methods

+
+

The comment for new methods.

+
+ +

Code Templates

+

+ + + + + + + + + + + + + + + + + + + + +
+

Template Name

+
+

Description

+
+

Method body

+
+

The 'Method body' templates are used when new method is created.

+
+

Constructor body

+
+

The 'Constructor body' templates are used when a constructor is created.

+
+

Destructor body

+
+

The 'Destructor body' templates are used when the destructor is created.

+
+ +

File Templates

+File templates can not only be defined and modified for C/C++ files, but also for other content types, like Assembly files or plain text files. +The New File from Template wizard can be used to create new files based on one of the templates defined in this page. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Template Name

+
+

Description

+
+

Default C++ source template

+
+

Used by the New Class wizard and the New Source File wizard when a new C++ source file is created.

+

The template can specify where comments are added. Note that the template can contain the variable ${typecomment} and ${filecomment} that will be substituted by the evaluation of the Types respectively Files comment template.

+
+

Default C++ header template

+
+

Used by the New Class wizard and the New Header File wizard when a new C++ header file is created.

+

The template can specify where comments are added. Note that the template can contain the variable ${typecomment} and ${filecomment} that will be substituted by the evaluation of the Types respectively Files comment template.

+
+

Default C source template

+
+

Used by the New Source File wizard when a new C source file is created.

+

The template can specify where comments are added. Note that the template can contain the variable ${typecomment} and ${filecomment} that will be substituted by the evaluation of the Types respectively Files comment template.

+
+

Default C header template

+
+

Used by the New Header File wizard when a new C source file is created.

+

The template can specify where comments are added. Note that the template can contain the variable ${typecomment} and ${filecomment} that will be substituted by the evaluation of the Types respectively Files comment template.

+
+

Other file templates

+
+

File templates can be defined for other content types, e.g. Assembly or plain text.

+
+ +

Edit Template dialog

+ +

The following fields and buttons appear in the dialog:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Action

+
+

Description

+
+

Name

+
+

The name of the template. Only available for file templates.

+
+

Type

+
+

The file type (content type) of the template. Only available for file templates.

+
+

Description

+
+

A description of the template

+
+

Pattern

+
+

The template pattern.

+
+

Insert Variables...

+
+

Displays a list of pre-defined template specific variables.

+
+ +

Related concepts
+Coding aids

+

Related reference +
+C/C++ editor preferences

+IBM Copyright Statement + + + diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_code_temp.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_code_temp.htm index 98e20610c6f..6b8802f8726 100644 --- a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_code_temp.htm +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_code_temp.htm @@ -11,7 +11,7 @@

Templates preferences

-

Use the Templates preference panel to manipulate any of the common code templates predefined within CDT or create your own. To modify, delete, export, +

Use the Templates preference panel to manipulate any of the common templates predefined within CDT or create your own. To modify, delete, export, import, or create your own templates click Window > Preferences > C/C++ > Templates.

Code Templates Preferences @@ -23,15 +23,15 @@ import, or create your own templates click Window > Preferences > C/C++ - + - + - + @@ -43,15 +43,15 @@ import, or create your own templates click Window > Preferences > C/C++ - + - + - +
New...
Opens the New Template dialog to create a new code template.Opens the New Template dialog to create a new template.
Edit...
Opens the Edit Template dialog to edit the selected code template.Opens the Edit Template dialog to edit the selected template.
Remove
Removes the selected code templates from the list.Removes the selected templates from the list.
Restore Removed
Import...
Imports a code template.Imports a template.
Export...
Exports the selected code templates.Exports the selected templates.
Use code formatter
Enable to apply the currently selected code style to the code template.Enable to apply the currently selected code style to the template.
diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_con_assist.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_con_assist.htm index cd250fca7d6..6fc0dee9e0f 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_con_assist.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_con_assist.htm @@ -13,8 +13,8 @@

Working with Content Assist

The following topics provide information about code entry aids:

Using Content Assist
- Creating and editing code templates
- Importing and exporting code templates
+ Creating and editing templates
+ Importing and exporting templates

QNX Copyright Statement

diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_tasks.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_tasks.htm index fd69f578260..003abd3066a 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_tasks.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_tasks.htm @@ -30,8 +30,8 @@ Commenting out code
Working with Content Assist
Using Content Assist
- Creating and editing code templates
- Importing and exporting code templates
+ Creating and editing templates
+ Importing and exporting templates
Shifting lines of code to the right or left
Navigating to C/C++ declarations
Navigating to C/C++ definitions
diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_write_code.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_write_code.htm index 81cac5f3477..3384a0e126c 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_write_code.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_o_write_code.htm @@ -16,8 +16,8 @@ Commenting out code
Working with Content Assist
Using Content Assist
- Creating and editing code templates
- Importing and exporting code templates
+ Creating and editing templates
+ Importing and exporting templates
Shifting lines of code to the right or left
Searching for C/C++ elements
Selection Searching for C/C++ elements
diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_add_codetemp.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_add_codetemp.htm index 50522d3ad6d..d7bc33214a5 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_add_codetemp.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_add_codetemp.htm @@ -4,19 +4,19 @@ -Creating and editing code templates +Creating and editing templates -

Creating and editing code templates

-

Content Assist uses code templates to enable you to quickly make use of commonly used code segments.

-

To create a code template:

+

Creating and editing templates

+

Content Assist uses templates to enable you to quickly make use of commonly used code segments.

+

To create a template:

  1. Click Window > Preferences.
  2. -
  3. Expand C/C++, expand Content Assist and select Templates.
  4. +
  5. Expand C/C++, expand Editor and select Templates.
  6. Click New.


    Creating a new Code Template Window


    @@ -25,20 +25,20 @@
    • In the Name field, type a template name.
    • In the Context drop down list, select the context type for the new template; either C/C++ or a Comment.
    • -
    • In the Description field, type a description for the new code template.
    • +
    • In the Description field, type a description for the new template.
    • In the Pattern field, type the code for this template.
    • Click Insert Variable to add a variable from the list to the code you have entered in the Pattern field.
  7. Click OK.
    - The new code template displays in the Templates list.
  8. + The new template displays in the Templates list.
-

To edit a code template:

+

To edit a template:

  1. Click Window > Preferences.
  2. -
  3. Expand C/C++, expand Content Assist and select Templates.
  4. +
  5. Expand C/C++, expand Editor and select Templates.
  6. Click Edit. The Edit Template dialog opens.


    Editing a Code Template


  7. @@ -63,9 +63,8 @@

    Related tasks
    Using Content Assist
    -Importing and exporting code templates

    +Importing and exporting templates

    Related reference
    -Code Templates page, Preferences window
    Code Templates page

    QNX Copyright Statement diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_comment_out.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_comment_out.htm index 46ebc3e3faa..ea513f2f0e5 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_comment_out.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_comment_out.htm @@ -42,8 +42,7 @@ described above.

    Working with Content Assist

    Related reference
    -C/C++ editor, code templates and search -preferences

    +C/C++ editor preferences

    IBM Copyright Statement diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_contentassist.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_contentassist.htm index 5e935cbb7ed..6c6d9dd087c 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_contentassist.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_contentassist.htm @@ -12,15 +12,15 @@

    Using Content Assist

    -

    Use Content Assist to insert C/C++ elements of your project, and code templates into your code. You can insert a code template into your source code rather than retyping +

    Use Content Assist to insert C/C++ elements of your project, and templates into your code. You can insert a template into your source code rather than retyping commonly-used snippets of code.

    -

    To insert a code template or element:

    +

    To insert a template or element:

      -
    1. In the C/C++ editor, type at least the first letter of a code template or +
    2. In the C/C++ editor, type at least the first letter of a template or element then Ctrl+Space.
      - A list displays the code templates + A list displays the templates followed by the elements that start with the letter combination you typed.

    3. Editor View showing Content Assist Example @@ -63,8 +63,8 @@ commonly-used snippets of code.

      Content Assist

      Related tasks
      -Creating and editing code templates
      -Importing and exporting code templates

      +Creating and editing templates
      +Importing and exporting templates

      Related reference
      Content Assist page, Preferences window
      diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_imp_code_temp.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_imp_code_temp.htm index 8e791624f28..be08f7cbd48 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_imp_code_temp.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_imp_code_temp.htm @@ -3,17 +3,17 @@ -Importing and exporting code templates +Importing and exporting templates -

      Importing and exporting code templates

      +

      Importing and exporting templates

      -

      You can import and export code templates.

      +

      You can import and export templates.

      -

      Note: A code template must be an .xml file formatted as follows:

      +

      Note: A template must be an .xml file formatted as follows:

      <?xml version="1.0" encoding="UTF-8" ?> 
       <templates>
      @@ -21,25 +21,25 @@
       </templates>
      Code Templates Preferences -

      To import a code template

      +

      To import a template

      1. Click Window > Preferences.
      2. -
      3. Expand C/C++, and click Code Templates. +
      4. Expand C/C++, expand Editor and click Templates.
      5. Click Import.
      6. Select the template file that you want to import.
      7. Click OK.
        - The code template list is updated to include the template that you imported.
      8. + The template list is updated to include the template that you imported.
      -

      To export a code template

      +

      To export a template

      1. Click Window > Preferences.
      2. -
      3. Expand C/C++, and click Code Templates.
      4. -
      5. Select the templates that you want to export and click the Export... or Export All... button. The Exporting x dialog opens where x is the number of code templates that you are exporting.
      6. -
      7. In File name box, type the path  where you want your code templates file to be saved.
      8. +
      9. Expand C/C++, expand Editor and click Templates.
      10. +
      11. Select the templates that you want to export and click the Export... button. The Export Templates dialog opens.
      12. +
      13. In File name box, type the path  where you want your templates file to be saved.
      14. Click Save.
        - The templates.xml file containing the code templates you exported is saved in your file system.
      15. + The templates.xml file containing the templates you exported is saved in your file system.

      Related concepts @@ -48,11 +48,10 @@

      Related tasks
      Using Content Assist
      -Creating and editing code templates

      +Creating and editing templates

      Related reference
      -Code Templates page, Preferences window
      -Code Templates page

      +Templates page

      IBM Copyright Statement diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_shift_code.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_shift_code.htm index 37889481717..1718ae40a79 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_shift_code.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_shift_code.htm @@ -37,8 +37,7 @@ editor.

      Customizing the C/C++ editor

      Related reference
      -C/C++ editor, code templates and search -preferences

      +C/C++ editor preferences

      IBM Copyright Statement diff --git a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_show_proj_files.htm b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_show_proj_files.htm index 581d133a0fc..83005767a5c 100644 --- a/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_show_proj_files.htm +++ b/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_show_proj_files.htm @@ -46,8 +46,7 @@ view

      Related reference
      -C/C++ editor, code templates and search -preferences

      +C/C++ editor preferences

      IBM Copyright Statement diff --git a/doc/org.eclipse.cdt.doc.user/topics_Reference.xml b/doc/org.eclipse.cdt.doc.user/topics_Reference.xml index 5aab9e180ec..e623682d393 100644 --- a/doc/org.eclipse.cdt.doc.user/topics_Reference.xml +++ b/doc/org.eclipse.cdt.doc.user/topics_Reference.xml @@ -59,6 +59,7 @@ + diff --git a/doc/org.eclipse.cdt.doc.user/topics_Tasks.xml b/doc/org.eclipse.cdt.doc.user/topics_Tasks.xml index f092b515d30..628a9fdd9d5 100644 --- a/doc/org.eclipse.cdt.doc.user/topics_Tasks.xml +++ b/doc/org.eclipse.cdt.doc.user/topics_Tasks.xml @@ -20,8 +20,8 @@ - - + +