From aa4e2c0a65faf14b91eeca016f1809d288beff2d Mon Sep 17 00:00:00 2001 From: eiffel-org Date: Mon, 21 Nov 2016 20:31:56 +0000 Subject: [PATCH] Update wikipage Code Templates. (Signed-off-by:javier). git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1673 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../eiffelstudio-editor/Code-Templates.wiki | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/documentation/trunk/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki b/documentation/trunk/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki index dd107b0b..f31cb2b2 100644 --- a/documentation/trunk/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki +++ b/documentation/trunk/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki @@ -26,41 +26,31 @@ There are two kinds of template: Code templates are part of EiffelStudio’s code completion mechanism. Code completion lets you choose a code template at the same place where it offers you features to call: when you type a dot character “.” after the name of an applicable local variable, attribute or function, a menu appears: -[[Image:target_template_1_0]] +[[Image:target_template_1_0]] + Figure 1. Auto-completion with code template option If there are any applicable targeted templates, the first entry says “Code templates (CTRL-Space)” and you can click it to get a list of applicable templates: [[Image:target_template_1_1]] + Figure 2. Auto-completion with code templates option list +As suggested, you can also type Control-space to get the same effect. If you find a template that you like, just click it (or navigate to it in the list using the up and down arrow keys, then type Return). - -==Templates Definition== -* Indexing notes at top level class -** `template_version`, it's used to select the version of the given template, if not present, it will be parsed using the latest version, -at the moment version is `1.0` -* Every template should inherit from the TEMPLATE class - class ARRAY_TEMPLATE [T -> COMPARABLE] inherit TEMPLATE [ARRAY [T]] -* Multiple Generic Constraints is not supported - class EXAMPLE_TEMPLATE [T -> {TYPE_1, TYPE_2}] -* A file could have multiple code templates definitions. -** Queries -** Commands -* Code templates could be Global/Target-less or applicable to a given Context -Queries and Commands accept multiple arguments like (a:T1; b:T2; c:T3), if any, will be used as input arguments where the default values will be filled with defaults if they exist. -* Target Templates inherit from TEMPLATE [T] -These templates will inherit a feature `target` with the type of the context, the generic type. -* Targetless Templates inherit from TEMPLATE -These templates does not have the feature `target`. -* Metadata: it’s possible to add metadata to code templates using note clause -** title: title of template, if not present we will use the name of the feature defined in the template. -** tags: List of tags to classify the template. -** default: use to define default values for input arguments. +It's also possible to use code templates without a target after type Control-Space, if there are any applicable targetless templates, the first entry says “Code templates (CTRL-Space)” and you can click it to get a list of applicable templates. Choose the desired one by clicking or navigating. + +[[Image:targetless_template_1_3]] +Figure 3. Targetless Auto-completion with code template option + + +When you insert a template into your code, it will often have some highlighted fields, corresponding to the template arguments, for example the lower and upper bounds of the array slice whose maximum you need: + + +[[Image:targetless_template_1_4|780px]] +Figure 4. Targetless Auto-completion with code templates option list. - -==Templates Skeleton== ====Context templates==== The next example shows how to define a template that will be applicable to types that conforms ARRAY [COMPARABLE].