From 246745930dc63e678072f10155aebe600214c464 Mon Sep 17 00:00:00 2001 From: eiffel-org Date: Fri, 14 Apr 2023 08:22:51 +0000 Subject: [PATCH] Updated wikipage Code Templates. (Signed-off-by:jocelyn). git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2392 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../eiffelstudio-editor/Code-Templates.wiki | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/documentation/22.12/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki b/documentation/22.12/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki index 3afda6c7..97be35fa 100644 --- a/documentation/22.12/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki +++ b/documentation/22.12/eiffelstudio/eiffelstudio-reference/eiffelstudio-editor/Code-Templates.wiki @@ -1,4 +1,4 @@ -[[Property:modification_date|Mon, 02 Sep 2019 08:02:24 GMT]] +[[Property:modification_date|Fri, 14 Apr 2023 08:22:51 GMT]] [[Property:publication_date|Mon, 02 Sep 2019 08:02:24 GMT]] [[Property:uuid|7CCF602E-0B79-49C2-93FE-39C90CBE4E35]] [[Property:link_title|Code Templates]] @@ -106,6 +106,7 @@ To offer templates as part of code completion, EiffelStudio looks in two locatio ** Windows: C:/Users/your_user_name/Documents/Eiffel User Files/16.11/templates/code If you define templates for your own specific use, store them in the second location. +The template file should be an Eiffel file (with `e` file extension). == Defining a targeted template == Here is how we defined the template used in the above targeted example: @@ -147,11 +148,34 @@ This class defines two targeted templates: ''maximum'' for the maximum of an ent To specify the target type, here arrays, just use it as the actual generic parameters of TEMPLATE (which is a generic class). Here indeed, the the definition starts as - class ARRAY_TEMPLATE [T -> COMPARABLE] inherit - - TEMPLATE [ARRAY [T]] +class ARRAY_TEMPLATE [T -> COMPARABLE] + +inherit + TEMPLATE [ARRAY [T]] +Another example, without generic parameters: + + +class STRING_UTF_8_TEMPLATE [T -> READABLE_STRING_GENERAL] + +inherit + TEMPLATE [T] + +feature -- Templates + + to_utf_8: STRING_8 + -- STRING_8 string from `target'. + note + title: "To UTF-8 STRING" + tags: "Unicode, String, STRING" + do{UTF_CONVERTER}.utf_32_string_to_utf_8_string_8 (target)end + +end + +(note: in that example, there is no space after the `do` and before the `end`, so the template is applied without adding extra unwanted spaces) + +== Integration within EiffelStudio == The correspondence between what you write in the template definition and what appears in EiffelStudio, as shown in previous sections, is straightforward: @@ -162,7 +186,6 @@ The correspondence between what you write in the template definition and what ap == Defining a targetless template == - For a targetless template, just just use TEMPLATE without a generic parameter: