How to make a YASnippet that inserts generated setters and getters at the appropiate place?

278 Views Asked by At

In the answers to How to implement a 'generate getter/setter' for a Java Class in emacs? there are several YASnippets that solve the problem of generating setters and getters as you create instance variables in Java. However, neither appropriately handles sorting of setter and getter methods as they are created. For instance, if you have two instance variables and add a third between the current declarations the setter and getter methods will end up directly after the second instance variable with the declaration of the third instance variable following the methods. Is there a way to write a YASnippet such that it will insert the setters and getters at the appropriate place, i.e. with the same sorting as the declarations of instance variables?

0

There are 0 best solutions below