Resayer and live templates. Get a list of parameters in a method

I want to create a live template with resharper that allows me to record input method input and method parameters, for example:

I have a method in my code:

public void searchByParams(String param1, String param 2) { SearchClass mySearchClass = new SearchClass(); mySearchClass.Search(param1, param2); } 

Now, I want to add a log, so far I have two live templates created using resharper:

Enter which template code:

 _logger.Info("Ingreso al método $METHOD_NAME$ "); 

And exit what template code:

 _logger.Info("Salida del método $METHOD_NAME$ "); 

for $ METHOD_NAME $, I selected a macro: "containing the name of a type member"

Then, after using these live templates, my method ends as follows:

 public void searchByParams(String param1, String param 2) { _logger.Info("Ingreso al método searchByParams "); SearchClass mySearchClass = new SearchClass(); mySearchClass.Search(param1, param2); _logger.Info("Salida del método searchByParams "); } 

what well.

Now I want to change my "Enter" template so that it inserts a list of arguments (in this example param1 and param2) and makes it suitable for use with methods with different numbers of input parameters and different types.

How can i do this?

I am using resharper 6.

Thanks in advance.

+4
source share
1 answer

I am not sure that this can be done in reality, and not on what I know. Today I discovered that I need the same thing, so I am making a function request for JetBrains. If you do not care, please vote for it.

0
source

Source: https://habr.com/ru/post/1403322/


All Articles