I would like to write a snippet to make value classes like the one below:
class Person
{
private var _name: String;
private var _age: int;
public function get name(): String { return _name; }
public function get age(): String { return age; }
public function Person(name: String, age: int)
{
_name = name;
_age = age;
}
}
a snippet to make value classes with one parameter would look something like the following:
public class ${1:MyClass}
{
private var _$2: $3;
public var get $2(): $3 { return _$2; }
public function $1($2: $3)
{
_$2 = $2;
}
}
But I would like to extend this snippet template to handle infinite fields.
I can see no system that facilitates this in ST,
as a system like this needs to repeat blocks of text.
I imagine the system would need to adapt the $ token to indicate a repeating block.
The {} brackets would define the repeating block(s)
A repeat trigger character would also need to be defined to indicate when another repetition should be started.
In the case of the value class example the repeat character would be a comma ‘,’
Does this feature exist in ST.
If not, has it been discussed?
Thanks for your time
Brian
public class ${1:MyClass}
{
// the first repeating block, the * char defines a repeating block
${2*:
private var _$2.1: $2.2;
public var get $2.1(): $2.2 { return _$2.1; }
}
// constructor argument are the second repating block
public function $1(${2*',':$2.1: $2.2}) // the repeat character ',' is defined here
{
// third repeating block
${2*:
_$2.1 = $2.2;
}
}
}