How to create custom template parameter macro?

Dear ReSharper Community, if I create a Live, Surround or File Template I have the option to quote a parameter with the $ symbol. For example: $FUNCNAME$.
Now I have the option to choose a macro, but in my case I would need a macro which returns the project name in all caps with no extension.

Thus I need to create my own macro which can be selected under “Choose macro”. A macro which is close to my needs is called "Current file name in upper case with all non-alphanumeric replaced with underscores".

Has anyone an idea how to archive this?

2
3 comments

Hello,

It's currently not possible to add a custom macro, all the predefined macros are implemented in R# itself. Since you want the name of the current project, I guess you need to use the "Name of the current project" macro. Or did you mean the name of the current file?

0

Hello @...,
thank you for your response. I need it differently:
“Name of the current project in upper case with all non-alphanumeric replaced with underscores” and “Current file name in upper case with all non-alphanumeric replaced with underscores without file extension.”

The existing macros “Name of the current project” and “Current file name in upper case with all non-alphanumeric replaced with underscores” are close to my needs, but I need them exactly as described before.
Otherwise, the replaced parameter doesn't match to the defines in my source code.

Example use case: File Template “MyHeader”:

…
#ifdef $filenameAllUpper$_DECL
[…]
#ifdef $projectnameAllUpper$_BUILD
…

Result should be:


#ifdef EXAMPLE_FILENAME_DECL […] #ifdef EXAMPLE_PROJECTNAME_BUILD …

What I can achieve with the current macros:


#ifdef EXAMPLE_FILENAME_CPP_DECL […] #ifdef ExampleProjectname_BUILD …

EXAMPLE_FILENAME_CPP: I need to remove the _CPP somehow.
ExampleProjectname: Should be all upper case and all non-alphanumeric replaced with underscores.

0

Sorry, I don't think this is possible right now.

0

Please sign in to leave a comment.