I was fiddling with a code template I'd written [or more likely, "borrowed" from somewhere] which I've been using for completing Read-Write and Read-Only properties. Originally it was set up with two points ... one for the property variable ["ident"] and one for it's type ["type"].
When setting the "ident" variable point, the template was automatically filling in the Getter and Setter following the "F" for me and prior to using Code Completion [Ctrl-Shift-C] I would have to make sure I replaced the "F" with either Get or Set if I wanted actual Getter or Setter methods.
This original CDATA:
<![CDATA[property |ident|: |type| read F|ident|;|end|]]>
produces this code:
property Test: Integer read FTest write FTest;
I didn't know if sticking two point variable side-by-side would work. I can't imagine why it wouldn't, but you never know. So, I experimented and sure enough adding a couple of "setter" and "getter" points and having them that close to another point in the CData - wasn't a problem at all.
Now after setting [or leaving the default] property type, it's either Tab to leave the default "Get" or "Set" -or- replace the appropriate one [or both] with "F".
Now, it's as simple as:
"proprw [tab/space] Test [tab][tab][tab[tab]" to get:
property Test: Integer read GetTest write SetTest;
- or -
"proprw [tab/space] Test [tab][tab] F [tab] F [tab] to get:
property Test: Integer read FTest write FTest;
Code templates simply rock! A little front end work, to accomplish a lot of back end work ... much, much faster.
Here's the modified version that I use for a read-write property ... enjoy. Note that I've changed the point names to something meaningful ... "ident" wasn't really all that descriptive.
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates" version="1.0.0">
<template name="proprw" invoke="auto">
<description>Property with Getter and Setter.</description>
<author>tdh</author>
<point name="Name">
<text>Name</text>
<hint>the Name for the property</hint>
</point>
<point name="Type">
<text>Integer</text>
<hint>the Type for the property</hint>
</point>
<point name="Getter">
<text>Get</text>
<hint>the property Getter</hint>
</point>
<point name="Setter">
<text>Set</text>
<hint>the property Setter</hint>
</point>
<code language="Delphi" delimiter="|">
<![CDATA[property |Name|: |Type| read |Getter||Name| write |Setter||Name|;|end|]]>
</code>
</template>
</codetemplate>
Copy the code above into a text file, and save it as:
C:\My Documents\RAD Studio\code_templates\PropertyGetSet.xml
I'll leave creating the Read-Only derivative to you.
Note: I had a look at the Delphi Wiki and did find one where the author was "twm". It's probable that's where I got the original that I was working with so apologies to "twm" if it appears that I'm taking credit for your work - last thing I want to do, honestly.
Thanks for stopping by ...
Dave